Skip to content

Commit

Permalink
fix: css.extract options handling
Browse files Browse the repository at this point in the history
close #1061
  • Loading branch information
yyx990803 committed Apr 27, 2018
1 parent 9cfafea commit 8e72943
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
9 changes: 3 additions & 6 deletions packages/@vue/cli-service/lib/config/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

2 comments on commit 8e72943

@unicape
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尤大大 build 之后部署到服务器报错
Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin, refer to https://github.com/webpack/extract-text-webpack-plugin for the usage example
10分钟前我刚更新了vue-cli

@unicape
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

解决了 要node9.x以上

Please sign in to comment.