mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Merge branch 'tapable' of github.com:Atinux/nuxt.js into tapable
This commit is contained in:
commit
79a09aa4fa
@ -282,36 +282,30 @@ export default class Builder extends Tapable {
|
|||||||
|
|
||||||
// Start Builds
|
// Start Builds
|
||||||
return parallel(this.compiler.compilers, compiler => new Promise((resolve, reject) => {
|
return parallel(this.compiler.compilers, compiler => new Promise((resolve, reject) => {
|
||||||
let _resolved = false
|
|
||||||
const handler = (err, stats) => {
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (_resolved) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_resolved = true
|
|
||||||
if (err) {
|
|
||||||
return reject(err)
|
|
||||||
}
|
|
||||||
if (!this.options.dev) {
|
|
||||||
// Show build stats for production
|
|
||||||
console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console
|
|
||||||
if (stats.hasErrors()) {
|
|
||||||
return reject(new Error('Webpack build exited with errors'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
if (this.options.dev) {
|
if (this.options.dev) {
|
||||||
|
// --- Dev Build ---
|
||||||
if (compiler.options.name === 'client') {
|
if (compiler.options.name === 'client') {
|
||||||
// Client watch is started by dev-middleware
|
// Client watch is started by dev-middleware
|
||||||
resolve()
|
resolve()
|
||||||
} else {
|
} else {
|
||||||
// Build and watch for changes
|
// Build and watch for changes
|
||||||
compiler.watch(this.options.watchers.webpack, handler)
|
compiler.watch(this.options.watchers.webpack, (err) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err)
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Production build
|
// --- Production build ---
|
||||||
compiler.run(handler)
|
compiler.run((err, stats) => {
|
||||||
|
// Show build stats for production
|
||||||
|
console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
return reject(new Error('Webpack build exited with errors'))
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user