mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 21:32:03 +08:00
Frontend: Add build:stats for analysing bundles (#94729)
* build(webpack): add a stats config and build:stats script for analysing bundles locally * chore(yarn): dedupe lock file * feat(webpack): use bundle analyser by default, env vars for additional plugins
This commit is contained in:
35
scripts/webpack/webpack.stats.js
Normal file
35
scripts/webpack/webpack.stats.js
Normal file
@ -0,0 +1,35 @@
|
||||
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const { merge } = require('webpack-merge');
|
||||
|
||||
const prodConfig = require('./webpack.prod.js');
|
||||
|
||||
module.exports = (env = {}) => {
|
||||
const config = { plugins: [new BundleAnalyzerPlugin()] };
|
||||
|
||||
// yarn build:stats --env doctor
|
||||
if (env.doctor) {
|
||||
config.plugins.push(
|
||||
new RsdoctorWebpackPlugin({
|
||||
supports: {
|
||||
// disable rsdoctor bundle-analyser
|
||||
generateTileGraph: false,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// disable hashing in output filenames to make them easier to identify
|
||||
// yarn build:stats --env doctor --env namedChunks
|
||||
if (env.namedChunks) {
|
||||
config.optimization = {
|
||||
chunkIds: 'named',
|
||||
};
|
||||
config.output = {
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[name].js',
|
||||
};
|
||||
}
|
||||
|
||||
return merge(prodConfig(env), config);
|
||||
};
|
Reference in New Issue
Block a user