pref: JS bundling improvements (#1461)

* perf: Split only initial vendors
This commit is contained in:
Tom Moor
2020-08-17 22:09:12 -07:00
committed by GitHub
parent d885252fb0
commit 0555fd2caa
2 changed files with 34 additions and 20 deletions

View File

@ -10,7 +10,7 @@ require('dotenv').config({ silent: true });
module.exports = { module.exports = {
output: { output: {
path: path.join(__dirname, 'dist'), path: path.join(__dirname, 'dist'),
filename: 'bundle.js', filename: '[name].[hash].js',
publicPath: '/static/', publicPath: '/static/',
}, },
module: { module: {
@ -64,4 +64,17 @@ module.exports = {
stats: { stats: {
assets: false, assets: false,
}, },
optimization: {
runtimeChunk: 'single',
moduleIds: 'hashed',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'initial',
},
},
},
}
}; };

View File

@ -7,17 +7,18 @@ const TerserPlugin = require('terser-webpack-plugin');
commonWebpackConfig = require('./webpack.config'); commonWebpackConfig = require('./webpack.config');
productionWebpackConfig = Object.assign(commonWebpackConfig, { productionWebpackConfig = Object.assign(commonWebpackConfig, {
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[contenthash].js',
publicPath: '/static/',
},
cache: true, cache: true,
mode: "production", mode: "production",
devtool: 'source-map', devtool: 'source-map',
entry: ['./app/index'], entry: ['./app/index'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.[hash].js',
publicPath: '/static/',
},
stats: "normal", stats: "normal",
optimization: { optimization: {
...commonWebpackConfig.optimization,
minimizer: [ minimizer: [
new TerserPlugin({ new TerserPlugin({
terserOptions: { terserOptions: {