Add process.generate

This commit is contained in:
Sebastien Chopin 2017-08-17 14:43:51 +02:00
parent e510136a5a
commit 42d967c27b
4 changed files with 11 additions and 3 deletions

View File

@ -27,6 +27,7 @@ export default class Builder extends Tapable {
constructor (nuxt) {
super()
this.nuxt = nuxt
this.generate = false // Flag to know if the build is for a generated app
this.options = nuxt.options
// Fields that set on build
@ -88,6 +89,10 @@ export default class Builder extends Tapable {
})
}
forGenerate() {
this.generate = true
}
async build () {
// Avoid calling build() method multiple times when dev:true
/* istanbul ignore if */

View File

@ -31,7 +31,8 @@ export default class Generator extends Tapable {
await this.nuxt.ready()
// Start build process
if (this.builder && build) {
if (build) {
this.builder.forGenerate() // Add flag to set process.generate
await this.builder.build()
}

View File

@ -103,7 +103,8 @@ export default function webpackClientConfig () {
'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV || (this.options.dev ? 'development' : 'production')),
'process.env.VUE_ENV': JSON.stringify('client'),
'process.browser': true,
'process.server': false
'process.server': false,
'process.generate': this.generate
}))
)

View File

@ -44,7 +44,8 @@ export default function webpackServerConfig () {
'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV || (this.options.dev ? 'development' : 'production')),
'process.env.VUE_ENV': JSON.stringify('server'),
'process.browser': false,
'process.server': true
'process.server': true,
'process.generate': this.generate
}))
])
})