Skip to content

Commit

Permalink
fix: reset NODE_ENV on production build end
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Jul 12, 2022
1 parent 10936cd commit d08356f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,14 @@ const parallelBuilds: RollupBuild[] = []
export async function build(
inlineConfig: InlineConfig = {}
): Promise<RollupOutput | RollupOutput[] | RollupWatcher> {
// NODE_ENV may be used as an "isProduction" flag for plugins
// Be sure to reset on exit (see finally block)
const initialNodeEnv = process.env.NODE_ENV
parallelCallCounts++
try {
return await doBuild(inlineConfig)
} finally {
process.env.NODE_ENV = initialNodeEnv
parallelCallCounts--
if (parallelCallCounts <= 0) {
await Promise.all(parallelBuilds.map((bundle) => bundle.close()))
Expand Down

0 comments on commit d08356f

Please sign in to comment.