Skip to content

Commit

Permalink
fix($core): set NODE_ENV before creating app (#1972)
Browse files Browse the repository at this point in the history
  • Loading branch information
kefranabg authored and meteorlxy committed Nov 27, 2019
1 parent 1a930dc commit 245be8d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/@vuepress/core/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/node/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion packages/@vuepress/core/lib/node/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 245be8d

Please sign in to comment.