fix(build): style not work in vue

This commit is contained in:
Clark Du 2020-08-19 18:21:49 +01:00 committed by pooya parsa
parent 2ee86286ad
commit dab1a831a6
2 changed files with 7 additions and 8 deletions

View File

@ -264,8 +264,11 @@ export default () => ({
embed: 'src'
}
},
css: {},
css: {
esModule: false
},
cssModules: {
esModule: false,
modules: {
localIdentName: '[local]_[hash:base64:5]'
}

View File

@ -25,11 +25,6 @@ export default class StyleLoader {
return this.options.build.extractCSS
}
get onlyLocals () {
// Not supported anymore by css-loader
return false // Boolean(this.isServer && this.extractCSS)
}
normalize (loaders) {
loaders = wrapArray(loaders)
return loaders.map(loader => (typeof loader === 'string' ? { loader } : loader))
@ -74,10 +69,11 @@ export default class StyleLoader {
}
css (options) {
options.onlyLocals = this.onlyLocals
const cssLoader = { loader: 'css-loader', options }
if (options.onlyLocals) {
if (this.isServer && this.extractCSS) {
options.modules = options.modules || {}
options.modules.exportOnlyLocals = true
return [cssLoader]
}