fix($core): set NODE_ENV before creating app (#1972)

This commit is contained in:
Franck Abgrall
2019-11-27 10:55:24 +08:00
committed by meteorlxy
parent 1a930dc22e
commit 245be8dbb8
3 changed files with 7 additions and 3 deletions
+6
View File
@@ -10,12 +10,18 @@ function createApp (options) {
}
async function dev (options) {
if (process.env.NODE_ENV === undefined) {
process.env.NODE_ENV = 'development'
}
const app = createApp(options)
await app.process()
return app.dev()
}
async function build (options) {
if (process.env.NODE_ENV === undefined) {
process.env.NODE_ENV = 'production'
}
const app = createApp(options)
await app.process()
return app.build()
+1 -2
View File
@@ -38,6 +38,7 @@ module.exports = class App {
*/
constructor (options = {}) {
this.isProd = process.env.NODE_ENV === 'production'
this.options = options
this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback')
logger.debug('sourceDir', this.sourceDir)
@@ -459,7 +460,6 @@ module.exports = class App {
*/
async dev () {
this.isProd = false
this.devProcess = new DevProcess(this)
await this.devProcess.process()
const error = await new Promise(resolve => {
@@ -489,7 +489,6 @@ module.exports = class App {
*/
async build () {
this.isProd = true
this.buildProcess = new BuildProcess(this)
await this.buildProcess.process()
await this.buildProcess.render()
@@ -18,7 +18,6 @@ const { normalizeHeadTag, applyUserWebpackConfig } = require('../util/index')
module.exports = class Build extends EventEmitter {
constructor (context) {
super()
process.env.NODE_ENV = 'production'
this.context = context
this.outDir = this.context.outDir
}