Skip to content

Commit fb1d282

Browse files
committed
Split polyfills and libs to separate chunks
1 parent a3895af commit fb1d282

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.DS_Store
22
node_modules
33
public/bundle.*
4+
public/libs_*
5+
public/runtime.*
6+
public/polyfills.*
47
package-lock.json
5-
yarn.lock
8+
yarn.lock

babel.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ module.exports = {
55
'@babel/preset-env',
66
{
77
loose: true,
8-
/** Only parse modules if testing. If not, let webpack handle it */
8+
// Only parse modules if testing. If not, let webpack handle it
99
modules: false,
10-
debug: true,
10+
// set to true to see which polyfill is added to each file
11+
debug: false,
1112
forceAllTransforms: true,
1213
useBuiltIns: 'usage',
1314
corejs: { version: 3, proposals: true },

webpack.config.js

+24
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,28 @@ module.exports = {
6161
}),
6262
],
6363
devtool: prod ? false : 'source-map',
64+
optimization: {
65+
// create a separate chunk for webpack runtime
66+
runtimeChunk: { name: 'runtime' },
67+
splitChunks: {
68+
chunks: 'all',
69+
minSize: 0,
70+
minChunks: 1,
71+
automaticNameDelimiter: '_',
72+
cacheGroups: {
73+
vendors: false,
74+
// node_modules thingies go to 'lib'
75+
libs: {
76+
test: /[\\/]node_modules[\\/]/,
77+
priority: -10,
78+
},
79+
// Chunk that contains used polyfills
80+
polyfills: {
81+
test: /core-js/,
82+
name: 'polyfills',
83+
priority: 10,
84+
},
85+
},
86+
},
87+
},
6488
};

0 commit comments

Comments
 (0)