我想提取' vue'一大块,' jquery'一大块与“vue'”相关的东西,如“vuex'”,“vue-router'另一块。以及CommonChunkPlugin应该怎么做?
这些代码是我的配置,它将vue和jquery与其他人联系起来
new webpack.optimize.CommonsChunkPlugin(
name: 'vendor',
minChunks: function(module, count) {
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf( path.join(__dirname, '../node_modules') ) === 0
)
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
})
entry: {
collegedaily: '.src/collegedaily/collegedaily.js',
editor: './src/editor/editor.js',
sharepage: './src/share/blog.js',
agreement: './src/agreement/agreement.js',
invitationCode: './src/invitationCode/invitationCode.js'
}
非常感谢你!
答案 0 :(得分:0)
您可以创建CommonsChunkPlugin的两个新实例,并使它们像这样
new webpack.optimize.CommonsChunkPlugin({
name: 'vue',
minChunks: function(module, count) {
return module.resource && (/vue/).test(module.resource)
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'jquery',
minChunks: function(module, count) {
return module.resource && (/jquery/).test(module.resource)
}
}),