Commit 5ddf07d8 authored by 邓晓峰's avatar 邓晓峰

feat: 优化生产环境打包splitChunks

parent d462f7f1
...@@ -50,13 +50,16 @@ module.exports = require('./webpack.base.babel')({ ...@@ -50,13 +50,16 @@ module.exports = require('./webpack.base.babel')({
concatenateModules: true, concatenateModules: true,
runtimeChunk: 'single', runtimeChunk: 'single',
splitChunks: { splitChunks: {
maxSize: 100 * 1024, // 控制包的最大字节数 minSize: 20000,
minSize: 10 * 1024, // 控制包的最小字节数 minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,// webpack4,5区别较大
maxInitialRequests: 30,// webpack4,5区别较大
enforceSizeThreshold: 50000,
cacheGroups: { cacheGroups: {
vendor: { vendor: {
chunks: 'all', chunks: 'all',
minSize: 0, maxInitialRequests: 5,
maxInitialRequests: 10,
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
name(module) { name(module) {
const packageName = module.context.match( const packageName = module.context.match(
...@@ -72,12 +75,37 @@ module.exports = require('./webpack.base.babel')({ ...@@ -72,12 +75,37 @@ module.exports = require('./webpack.base.babel')({
test: /[\\/]src[\\/]components[\\/]/, test: /[\\/]src[\\/]components[\\/]/,
name: 'biz-component', name: 'biz-component',
}, },
react: { arcgis_views: {
chunks: 'all', chunks: 'all',
minSize: 0, minSize: 0,
maxInitialRequests: 10, maxInitialRequests: 5,
test: /[\\/]node_modules[\\/]react-dom[\\/]/, priority: 20,
name: 'react-dom', test: /[\\/]node_modules[\\/]@arcgis[\\/]core[\\/]views[\\/]/,
name: 'arcgis_views',
},
arcgis_views_3d: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 5,
priority: 22,
test: /[\\/]node_modules[\\/]@arcgis[\\/]core[\\/]views[\\/]3d[\\/]/,
name: 'arcgis_views_3d',
},
arcgis_layers: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 5,
priority: 10,
test: /[\\/]node_modules[\\/]@arcgis[\\/]core[\\/]layers[\\/]/,
name: 'arcgis_layers',
},
arcgis_chunks: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 5,
priority: 30,
test: /[\\/]node_modules[\\/]@arcgis[\\/]core[\\/]chunks[\\/]/,
name: 'arcgis_chunks',
} }
}, },
}, },
......
...@@ -3,7 +3,7 @@ import './public-path'; ...@@ -3,7 +3,7 @@ import './public-path';
import '!file-loader?name=[name].[ext]!./images/favicon.ico'; import '!file-loader?name=[name].[ext]!./images/favicon.ico';
import './global.less'; import './global.less';
import 'animate.css/animate.css'; import 'animate.css/animate.css';
import 'antd/dist/antd.less'; // import 'antd/dist/antd.less';
import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions
import '@wisdom-utils/utils/lib/helpers/format'; import '@wisdom-utils/utils/lib/helpers/format';
import 'sanitize.css/sanitize.css'; import 'sanitize.css/sanitize.css';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment