Add webpack config for analyzing builds and improve ts speed
This commit is contained in:
parent
46f9a0fc8a
commit
5cb181f68c
4 changed files with 937 additions and 14 deletions
28
webpack.analyze.js
Normal file
28
webpack.analyze.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const { merge } = require('webpack-merge');
|
||||
|
||||
const prod = require('./webpack.prod');
|
||||
|
||||
const smp = new SpeedMeasurePlugin();
|
||||
|
||||
const config = merge(prod, {
|
||||
plugins: [
|
||||
new BundleAnalyzerPlugin({
|
||||
excludeAssets: /-json\..*\.chunk\.js$/
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
const searchPlugin = (name) => config.plugins.findIndex((e) => e.constructor.name === name);
|
||||
|
||||
// NOTE: We need to re-add the mini css plugin to workaround this issue
|
||||
// https://github.com/stephencookdev/speed-measure-webpack-plugin/issues/167
|
||||
const miniCssPluginIndex = searchPlugin('MiniCssExtractPlugin');
|
||||
const miniCssPlugin = config.plugins[miniCssPluginIndex];
|
||||
|
||||
const exportedConfig = smp.wrap(config);
|
||||
|
||||
exportedConfig.plugins[miniCssPluginIndex] = miniCssPlugin;
|
||||
|
||||
module.exports = exportedConfig;
|
Loading…
Add table
Add a link
Reference in a new issue