最近公司运营了两年的老项目突然在测试和生产环境部署后打开控制台出现浏览器崩溃的问题,找了很久终于解决了,我造
webpackConfig.optimization.splitChunks = {
...webpackConfig.optimization.splitChunks,
cacheGroups: {
base: {
// 关键就在于这里的目录匹配, 排除同名不在node_modules的目录
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom|react-redux|@reduxjs[\\/][^\\/]+)[\\/]/,
// 原配置: test: /(react|react-dom|react-dom-router|@reduxjs|react-redux)/,
chunks: 'all',
name: 'base-vendors',
priority: 110,
},
libraries: {
test: /[\\/]node_modules[\\/](?:@antv|@ant-design|antd|highcharts|echarts|lodash|moment|axios|zrender|file-saver|regl|gl|rc\-.+)([\\/]|$)/,
name: 'common-libraries',
chunks: 'all',
priority: 110,
},
commons: {
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
name: 'commons-vendors',
minChunks: 2,
priority: 100,
},
},
}