mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: css extraction with MiniCssExtractPlugin
This commit is contained in:
parent
17dbd2e947
commit
62cd611c19
@ -227,7 +227,10 @@ export default class WebpackBaseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CSS extraction
|
// CSS extraction
|
||||||
if (this.options.build.extractCSS) {
|
// MiniCssExtractPlugin does not currently supports SSR
|
||||||
|
// https://github.com/webpack-contrib/mini-css-extract-plugin/issues/48
|
||||||
|
// So we use css-loader/locals as a fallback (utils/style-loader)
|
||||||
|
if (this.options.build.extractCSS && !this.isServer) {
|
||||||
plugins.push(new MiniCssExtractPlugin(Object.assign({
|
plugins.push(new MiniCssExtractPlugin(Object.assign({
|
||||||
filename: this.getFileName('css')
|
filename: this.getFileName('css')
|
||||||
}, this.options.build.extractCSS)))
|
}, this.options.build.extractCSS)))
|
||||||
|
@ -70,7 +70,7 @@ export default class StyleLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loader: 'css-loader',
|
loader: (this.isServer && this.extractCSS) ? 'css-loader/locals' : 'css-loader',
|
||||||
options: {
|
options: {
|
||||||
sourceMap: this.sourceMap,
|
sourceMap: this.sourceMap,
|
||||||
minimize: !this.dev,
|
minimize: !this.dev,
|
||||||
@ -81,7 +81,7 @@ export default class StyleLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extract() {
|
extract() {
|
||||||
if (this.extractCSS) {
|
if (this.extractCSS && !this.isServer) {
|
||||||
return MiniCssExtractPlugin.loader
|
return MiniCssExtractPlugin.loader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user