Skip to content

Commit 046015f

Browse files
committed
fix: optimize split-chunks
1 parent 4a762f9 commit 046015f

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

ui/config-overrides.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -44,47 +44,45 @@ module.exports = {
4444
minChunks: 2,
4545
cacheGroups: {
4646
automaticNamePrefix: 'chunk',
47-
components: {
48-
test: /[\\/]components[\\/]/,
49-
name: 'components',
50-
priority: 14,
51-
reuseExistingChunk: true,
52-
minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
53-
chunks: 'initial',
54-
},
5547
mix1: {
48+
test: (module, chunks) => {
49+
return (
50+
module.resource &&
51+
(module.resource.includes('components') ||
52+
/\/node_modules\/react-bootstrap\//.test(module.resource))
53+
);
54+
},
5655
name: 'chunk-mix1',
57-
test: /[\/]node_modules[\/](i18next|lodash|marked|next-share)[\/]/,
5856
filename: 'static/js/[name].[contenthash:8].chunk.js',
59-
priority: 12,
57+
priority: 14,
6058
reuseExistingChunk: true,
61-
minChunks: 1,
59+
minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
6260
chunks: 'initial',
6361
},
6462
mix2: {
6563
name: 'chunk-mix2',
66-
test: /[\/]node_modules[\/](@remix-run|@restart|axios|diff)[\/]/,
64+
test: /[\/]node_modules[\/](i18next|lodash|marked|next-share)[\/]/,
6765
filename: 'static/js/[name].[contenthash:8].chunk.js',
68-
priority: 11,
66+
priority: 13,
6967
reuseExistingChunk: true,
7068
minChunks: 1,
7169
chunks: 'initial',
7270
},
73-
reactBootstrap: {
74-
name: 'react-bootstrap',
75-
test: /[\/]node_modules[\/](react-bootstrap)[\/]/,
71+
mix3: {
72+
name: 'chunk-mix3',
73+
test: /[\/]node_modules[\/](@remix-run|@restart|axios|diff)[\/]/,
7674
filename: 'static/js/[name].[contenthash:8].chunk.js',
77-
priority: 11,
75+
priority: 12,
76+
reuseExistingChunk: true,
7877
minChunks: 1,
7978
chunks: 'initial',
80-
reuseExistingChunk: true,
8179
},
8280
codemirror: {
8381
name: 'codemirror',
8482
test: /[\/]node_modules[\/](\@codemirror)[\/]/,
85-
priority: 9,
83+
priority: 10,
8684
reuseExistingChunk: true,
87-
minChunks: 1,
85+
minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
8886
chunks: 'initial',
8987
enforce: true,
9088
},
@@ -93,15 +91,15 @@ module.exports = {
9391
test: /[\/]node_modules[\/](\@lezer)[\/]/,
9492
priority: 9,
9593
reuseExistingChunk: true,
96-
minChunks: 1,
94+
minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
9795
chunks: 'initial',
9896
enforce: true,
9997
},
10098
reactDom: {
10199
name: 'react-dom',
102100
test: /[\/]node_modules[\/](react-dom)[\/]/,
103101
filename: 'static/js/[name].[contenthash:8].chunk.js',
104-
priority: 7,
102+
priority: 8,
105103
reuseExistingChunk: true,
106104
chunks: 'all',
107105
enforce: true,

0 commit comments

Comments
 (0)