Merge branch 'tapable' of github.com:Atinux/nuxt.js into tapable

This commit is contained in:
Sébastien Chopin 2017-06-18 15:54:58 +02:00
commit 79a09aa4fa

View File

@ -282,36 +282,30 @@ export default class Builder extends Tapable {
// Start Builds
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) {
// --- Dev Build ---
if (compiler.options.name === 'client') {
// Client watch is started by dev-middleware
resolve()
} else {
// 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 {
// Production build
compiler.run(handler)
// --- Production build ---
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()
})
}
}))
}