Code Splitting
SPA(Single Page Application)…
Application will get bigger and complecated.
SplitChunks optimization is good thing to do to avoid loading uncessesary js files over and over again.
webpack config
In your webpack.config, add optimization like
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'common',
chunks: 'initial',
enforce: true,
},
},
},
},
In your html, load common.js.
<script src="/assets/common.js"></script>