javascript - Webpack 优化问题
问题描述
迁移到 webpack 4.16.0 后,我遇到了问题。
我有 2 个这样定义的条目
entry: {
app: ['./src/app.js'],
index: ['./src/index.js']
},
和两个html页面
new HtmlWebpackPlugin({
template: './index.html',
filename: './index.html',
inject: 'head',
title: 'Content Stream',
chunks: ['index']
}),
new HtmlWebpackPlugin({
template: './app.html',
filename: './app.html',
title: 'Content Stream',
chunks: ['vendor', 'app']
})
使用webpack.optimization
(工作正常)
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
},
在我添加块index
之前,不会执行页面上捆绑的代码。vendor
但我在那里不需要它。
我收到index
块内容,但看起来和谐模块初始化运行部分已移至vendor
那么如何处理呢?
解决方案
推荐阅读
- arrays - 了解 dask 数组块
- javascript - 当我在 vuejs 中单击它时,如何将 div 中的文本从“暗”和“亮”来回切换?
- shiny - rmarkdown 渲染以使用与服务器相同的环境
- java - 当我尝试在 recyclerview 中读取本地 excel 文件时,什么也没有出现。什么可以解决这个问题?
- c - 在 OpenGL 中应用着色器时不会渲染纹理
- sql - SQL查询以获取单独列中每个元素的总和
- python - 如何在 django 上禁用自动文件上传?
- sql - 在 SQL Server 2019 中递归导入 JSON 文件
- c++ - 使用代理模式时如何区分读取和写入而不破坏与原始类型的交互和其他类型的成员访问?
- gdb - 无法在 Ubuntu 20.04 上构建 GDB master 2020 年 7 月 9 日