Skip to content

Commit 245be8d

Browse files
kefranabgmeteorlxy
authored andcommitted
fix($core): set NODE_ENV before creating app (#1972)
1 parent 1a930dc commit 245be8d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/@vuepress/core/lib/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ function createApp (options) {
1010
}
1111

1212
async function dev (options) {
13+
if (process.env.NODE_ENV === undefined) {
14+
process.env.NODE_ENV = 'development'
15+
}
1316
const app = createApp(options)
1417
await app.process()
1518
return app.dev()
1619
}
1720

1821
async function build (options) {
22+
if (process.env.NODE_ENV === undefined) {
23+
process.env.NODE_ENV = 'production'
24+
}
1925
const app = createApp(options)
2026
await app.process()
2127
return app.build()

packages/@vuepress/core/lib/node/App.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = class App {
3838
*/
3939

4040
constructor (options = {}) {
41+
this.isProd = process.env.NODE_ENV === 'production'
4142
this.options = options
4243
this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback')
4344
logger.debug('sourceDir', this.sourceDir)
@@ -459,7 +460,6 @@ module.exports = class App {
459460
*/
460461

461462
async dev () {
462-
this.isProd = false
463463
this.devProcess = new DevProcess(this)
464464
await this.devProcess.process()
465465
const error = await new Promise(resolve => {
@@ -489,7 +489,6 @@ module.exports = class App {
489489
*/
490490

491491
async build () {
492-
this.isProd = true
493492
this.buildProcess = new BuildProcess(this)
494493
await this.buildProcess.process()
495494
await this.buildProcess.render()

packages/@vuepress/core/lib/node/build/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const { normalizeHeadTag, applyUserWebpackConfig } = require('../util/index')
1818
module.exports = class Build extends EventEmitter {
1919
constructor (context) {
2020
super()
21-
process.env.NODE_ENV = 'production'
2221
this.context = context
2322
this.outDir = this.context.outDir
2423
}

0 commit comments

Comments
 (0)