mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 05:16:23 +10:00
fix($core): set NODE_ENV before creating app (#1972)
This commit is contained in:
committed by
meteorlxy
parent
1a930dc22e
commit
245be8dbb8
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user