Skip to content

Commit 8e72943

Browse files
committed
fix: css.extract options handling
close #1061
1 parent 9cfafea commit 8e72943

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

docs/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module.exports = {
4040
// CSS related options
4141
css: {
4242
// extract CSS in components into a single CSS file (only in production)
43+
// can also be an object of options to pass to extract-text-webpack-plugin
4344
extract: true,
4445

4546
// enable CSS source maps?

packages/@vue/cli-service/lib/config/css.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,15 @@ module.exports = (api, options) => {
103103

104104
// inject CSS extraction plugin
105105
if (extract) {
106-
const userOptions = options.extractCSS && typeof options.extractCSS === 'object'
107-
? options.extractCSS
106+
const extractOptions = userOptions.extract && typeof userOptions.extract === 'object'
107+
? userOptions.extract
108108
: {}
109109
webpackConfig
110110
.plugin('extract-css')
111111
.use(ExtractTextPlugin, [Object.assign({
112112
filename: `css/[name].[contenthash:8].css`,
113113
allChunks: true
114-
}, userOptions)])
114+
}, extractOptions)])
115115
}
116-
117-
// TODO document receipe for using css.loaderOptions to add `data` option
118-
// to sass-loader
119116
})
120117
}

packages/@vue/cli-service/lib/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const schema = createSchema(joi => joi.object({
1616
// css
1717
css: joi.object({
1818
modules: joi.boolean(),
19-
extract: joi.boolean(),
19+
extract: joi.alternatives().try(joi.boolean(), joi.object()),
2020
localIdentName: joi.string(),
2121
sourceMap: joi.boolean(),
2222
loaderOptions: joi.object({

0 commit comments

Comments
 (0)