Let webpack split chunks

This commit is contained in:
Jason Park
2019-01-24 02:26:01 -05:00
parent 4e8df588b9
commit f025e8827c

View File

@@ -84,7 +84,25 @@ module.exports = {
new MiniCssExtractPlugin({ filename: __DEV__ ? '[name].css' : '[name].[contenthash].css' }),
__PROD__ && new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
__DEV__ && new webpack.HotModuleReplacementPlugin(),
new webpack.HashedModuleIdsPlugin(),
// new BundleAnalyzerPlugin(),
]),
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 128 * 1024,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
},
mode: __DEV__ ? 'development' : 'production',
};