From 8e72943fcfd82b20d3bacabde640109f34674c19 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 27 Apr 2018 12:52:10 -0400 Subject: [PATCH] fix: css.extract options handling close #1061 --- docs/config.md | 1 + packages/@vue/cli-service/lib/config/css.js | 9 +++------ packages/@vue/cli-service/lib/options.js | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) 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({