diff --git a/docs/config.md b/docs/config.md index 75a994ab8f..6764c812b0 100644 --- a/docs/config.md +++ b/docs/config.md @@ -40,6 +40,7 @@ module.exports = { // CSS related options css: { // extract CSS in components into a single CSS file (only in production) + // can also be an object of options to pass to extract-text-webpack-plugin extract: true, // enable CSS source maps? diff --git a/packages/@vue/cli-service/lib/config/css.js b/packages/@vue/cli-service/lib/config/css.js index 9e1c1d3375..b262091bbf 100644 --- a/packages/@vue/cli-service/lib/config/css.js +++ b/packages/@vue/cli-service/lib/config/css.js @@ -103,18 +103,15 @@ module.exports = (api, options) => { // inject CSS extraction plugin if (extract) { - const userOptions = options.extractCSS && typeof options.extractCSS === 'object' - ? options.extractCSS + const extractOptions = userOptions.extract && typeof userOptions.extract === 'object' + ? userOptions.extract : {} webpackConfig .plugin('extract-css') .use(ExtractTextPlugin, [Object.assign({ filename: `css/[name].[contenthash:8].css`, allChunks: true - }, userOptions)]) + }, extractOptions)]) } - - // TODO document receipe for using css.loaderOptions to add `data` option - // to sass-loader }) } diff --git a/packages/@vue/cli-service/lib/options.js b/packages/@vue/cli-service/lib/options.js index 340369c4d5..94bd8bdfef 100644 --- a/packages/@vue/cli-service/lib/options.js +++ b/packages/@vue/cli-service/lib/options.js @@ -16,7 +16,7 @@ const schema = createSchema(joi => joi.object({ // css css: joi.object({ modules: joi.boolean(), - extract: joi.boolean(), + extract: joi.alternatives().try(joi.boolean(), joi.object()), localIdentName: joi.string(), sourceMap: joi.boolean(), loaderOptions: joi.object({