hotfix: extractCSS error in dev mode (#4892)

This commit is contained in:
Xin Du (Clark) 2019-01-29 22:07:13 +00:00 committed by pooya parsa
parent 2b30915950
commit a614fd3f81
2 changed files with 16 additions and 18 deletions

View File

@ -291,10 +291,6 @@ export function getNuxtConfig(_options) {
options.build.optimization.minimize = !options.dev options.build.optimization.minimize = !options.dev
} }
if (options.dev) {
options.build.extractCSS = false
}
// Enable optimizeCSS only when extractCSS is enabled // Enable optimizeCSS only when extractCSS is enabled
if (options.build.optimizeCSS === undefined) { if (options.build.optimizeCSS === undefined) {
options.build.optimizeCSS = options.build.extractCSS ? {} : false options.build.optimizeCSS = options.build.extractCSS ? {} : false

View File

@ -327,15 +327,27 @@ export default class WebpackBaseConfig {
} }
plugins() { plugins() {
const plugins = [new VueLoader.VueLoaderPlugin()] const plugins = []
Array.prototype.push.apply(plugins, this.options.build.plugins || [])
// Add timefix-plugin before others plugins // Add timefix-plugin before others plugins
if (this.options.dev) { if (this.options.dev) {
plugins.unshift(new TimeFixPlugin()) plugins.push(new TimeFixPlugin())
} }
// CSS extraction)
if (this.options.build.extractCSS) {
plugins.push(new ExtractCssChunksPlugin(Object.assign({
filename: this.getFileName('css'),
chunkFilename: this.getFileName('css'),
// TODO: https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/132
reloadAll: true
}, this.options.build.extractCSS)))
}
plugins.push(new VueLoader.VueLoaderPlugin())
Array.prototype.push.apply(plugins, this.options.build.plugins || [])
// Hide warnings about plugins without a default export (#1179) // Hide warnings about plugins without a default export (#1179)
plugins.push(new WarnFixPlugin()) plugins.push(new WarnFixPlugin())
@ -370,16 +382,6 @@ export default class WebpackBaseConfig {
} }
})) }))
// CSS extraction)
if (this.options.build.extractCSS) {
plugins.push(new ExtractCssChunksPlugin(Object.assign({
filename: this.getFileName('css'),
chunkFilename: this.getFileName('css'),
// TODO: https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/132
reloadAll: true
}, this.options.build.extractCSS)))
}
if (this.options.build.hardSource) { if (this.options.build.hardSource) {
plugins.push(new HardSourcePlugin(Object.assign({}, this.options.build.hardSource))) plugins.push(new HardSourcePlugin(Object.assign({}, this.options.build.hardSource)))
} }