【发布时间】:2017-12-21 13:56:50
【问题描述】:
我用我的项目的简单示例创建了 git repo https://github.com/paveleremin/webpack-build
问题是:如何用多个块构建它,例如:
- 组件(/app/components/ 文件夹中用于两个或多个模块的所有 js 文件)
- vendors(来自 /node_modules/ 和 /app/vendor/ 文件夹中的所有 js 文件,用于两个或多个模块)
- 清单(webpack js 代码、babel-polifill 等)
- 每个模块的 js 文件
现在构建有问题:
new webpack.optimize.CommonsChunkPlugin({
async: 'components',
children: true,
minChunks({ resource }, count) {
return resource && resource.includes(paths.components) && count > 1;
}
}),
new webpack.optimize.CommonsChunkPlugin({
async: 'vendors',
children: true,
minChunks({ resource }, count) {
console.log(resource, count);
return resource && (resource.includes(paths.nodeModules) || resource.includes(paths.vendor)) && count > 1;
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
- scUsedTwice 的来源是复制粘贴,并且存在于 login.js 和 dashboard.js 中 - 已解决
- 所有供应商都在 app.js 中
我自己尝试过,但是异步模块有问题。
【问题讨论】:
标签: javascript angularjs angular webpack