1 回答
TA贡献1858条经验 获得超8个赞
应该是 你 多个文件 依赖了相同的包 导致每一个文件都打包了多个重复的文件吧,应该用 CommonsChunkPlugin
插件 就可以解决了
new webpack.optimize.CommonsChunkPlugin({
name: "app",
async: "common-in-lazy",
children: true,
minChunks: ({ resource } = {}) => (
resource &&
resource.includes('node_modules') &&
/axios/.test(resource)
)
}),
new webpack.optimize.CommonsChunkPlugin({
name: "app",
children: true,
async: 'used-twice',
minChunks: (module, count) => (
count >= 2
),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
filename: "js/common.[chunkhash:8].js",
minChunks: ({ resource }) => (
resource &&
resource.indexOf('node_modules') >= 0 &&
resource.match(/\.js$/)
)
}),
添加回答
举报