我正在尝试根据wiki section从我的css中提取公共块。我知道这篇文档是为webpack 1编写的,但它是为webpack 2 seems like there is no corresponding example yet编写的。我使用的是以下的webpack配置:
module.exports = {
context: srcPath,
entry: {
foo: './css/pages/foo.css',
bar: './css/pages/bar.css'
},
output: {
path: distPath,
publicPath: '/assets/',
filename: '[name].js'
},
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract([
'css-loader'
])
}]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: 2
}),
new ExtractTextPlugin({
filename: 'css/[name].[contenthash:base64:5].css',
allChunks: true
})
]
};我不明白为什么common.css在构建之后没有出现。只有common.js,foo.js,bar.js,foo.css和bar.css。我是不是遗漏了什么?我是新来的webpack。
谢谢。
发布于 2017-03-27 16:53:39
参考https://webpack.js.org/plugins/commons-chunk-plugin/#options
minChunks意味着需要至少包含两次的模块将被捆绑到common.css中。
现在,没有关于入口foo.css和bar.css的详细信息,但您可以先查看它。:)
https://stackoverflow.com/questions/42015831
复制相似问题