javascript
const path = require('path');
const webpack = require('webpack');
module.exports = {
plugins: [new webpack.HashedModuleIdsPlugin()],
output: {filename: '[name].[contenthash].js'},
optimization: {
splitChunks: {
chunks: 'all',
minSize: 10000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 10,
maxInitialRequests: Infinity,
name: true,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${packageName.replace('@', '')}`;
},
priority: 10,
chunks: 'initial'
},
},
},
},
};