diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index df54a0c9ae98ed..1e528190f85b7d 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -1212,7 +1212,7 @@ function getConfigHash(environment: Environment): string { const { optimizeDeps } = config const content = JSON.stringify( { - define: config.keepProcessEnv + define: !config.keepProcessEnv ? process.env.NODE_ENV || config.mode : null, root: config.root,