Skip to content

Commit

Permalink
Define process.env.NODE_ENV in build process. (#10553)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterp authored May 11, 2024
1 parent 2eba782 commit fc1959e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vite/src/rsc/rscBuildClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export async function rscBuildClient(clientEntryFiles: Record<string, string>) {

const clientBuildOutput = await viteBuild({
envFile: false,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
build: {
// TODO (RSC): Remove `minify: false` when we don't need to debug as often
minify: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/rsc/rscBuildForServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export async function rscBuildForServer(
// TODO (RSC): No redwood-vite plugin, add it in here
const rscServerBuildOutput = await viteBuild({
envFile: false,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
ssr: {
// Inline every file apart from node built-ins. We want vite/rollup to
// inline dependencies in the server bundle. This gets round runtime
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/streaming/buildForStreamingServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export async function buildForStreamingServer({
emptyOutDir: true,
},
envFile: false,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
logLevel: verbose ? 'info' : 'warn',
})
}

0 comments on commit fc1959e

Please sign in to comment.