Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for only generating static env #77038

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,17 @@ export default async function build(
buildId,
})
})

// users might only want to inline env during experimental generate
// instead of also prerendering e.g. for testmode so exit after
if (config.experimental.generateOnlyEnv) {
Log.info(
'Only inlining static env due to experimental.generateOnlyEnv'
)
}
await flushAllTraces()
teardownTraceSubscriber()
process.exit(0)
}

const middlewareManifest: MiddlewareManifest = await readManifest(
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
excludeDefaultMomentLocales: z.boolean().optional(),
experimental: z
.strictObject({
generateOnlyEnv: z.boolean().optional(),
allowedDevOrigins: z.array(z.string()).optional(),
nodeMiddleware: z.boolean().optional(),
after: z.boolean().optional(),
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export interface LoggingConfig {
}

export interface ExperimentalConfig {
generateOnlyEnv?: boolean
allowedDevOrigins?: string[]
nodeMiddleware?: boolean
cacheHandlers?: {
Expand Down Expand Up @@ -1135,6 +1136,7 @@ export const defaultConfig: NextConfig = {
modularizeImports: undefined,
outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '',
experimental: {
generateOnlyEnv: false,
allowedDevOrigins: [],
nodeMiddleware: false,
cacheLife: {
Expand Down
Loading