@@ -8,9 +8,6 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
88const glob = require ( 'glob' )
99const { PurgeCSSPlugin } = require ( 'purgecss-webpack-plugin' )
1010
11- // const CompressionWebpackPlugin = require('compression-webpack-plugin')
12- // const SentryWebpackPlugin = require('@sentry/webpack-plugin')
13-
1411const HtmlMinimizerPlugin = require ( 'html-minimizer-webpack-plugin' )
1512const { EsbuildPlugin } = require ( 'esbuild-loader' )
1613
@@ -78,35 +75,23 @@ const prodWebpackConfig = merge(common, {
7875 maxAsyncRequests : 30 ,
7976 maxInitialRequests : 30 ,
8077 cacheGroups : {
81- // 框架代码分离
82- react : {
83- test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] ( r e a c t | r e a c t - d o m ) [ \\ / ] / ,
84- name : 'react' ,
85- chunks : 'all' ,
86- priority : 20 ,
87- } ,
88- // Ant Design分离
89- antd : {
90- test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] ( @ a n t - d e s i g n | a n t d ) [ \\ / ] / ,
91- name : 'antd' ,
92- chunks : 'all' ,
93- priority : 15 ,
94- } ,
95- // 其他第三方库
9678 vendor : {
97- test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
98- name : 'vendors ' ,
99- chunks : 'all' ,
79+ test : regVendor ,
80+ name : 'vendor ' ,
81+ minChunks : 1 ,
10082 priority : 10 ,
101- minChunks : 2 ,
102- } ,
103- // 公共代码
104- common : {
105- name : 'common' ,
106- minChunks : 2 ,
83+ enforce : true ,
10784 chunks : 'all' ,
108- priority : 5 ,
109- reuseExistingChunk : true ,
85+ } ,
86+ react : {
87+ test ( module ) {
88+ return module . resource && module . resource . includes ( 'node_modules/react' )
89+ } ,
90+ chunks : 'initial' ,
91+ filename : 'react.[contenthash].js' ,
92+ priority : 1 ,
93+ maxInitialRequests : 2 ,
94+ minChunks : 1 ,
11095 } ,
11196 } ,
11297 } ,
@@ -121,15 +106,4 @@ const prodWebpackConfig = merge(common, {
121106 } ,
122107} )
123108
124- // if (useSentryMap) {
125- // prodWebpackConfig.plugins.push(
126- // new SentryWebpackPlugin({
127- // release: packageJson.version,
128- // include: path.join(__dirname, '../dist/static/js'),
129- // configFile: '../.sentryclirc',
130- // urlPrefix: '~/static/js',
131- // })
132- // )
133- // }
134-
135109module . exports = prodWebpackConfig
0 commit comments