Skip to content

Instantly share code, notes, and snippets.

@BiosBoy
Created August 14, 2024 05:54
Show Gist options
  • Save BiosBoy/40b0954ade5f978dc20590fd6a647f8c to your computer and use it in GitHub Desktop.
Save BiosBoy/40b0954ade5f978dc20590fd6a647f8c to your computer and use it in GitHub Desktop.
# Webpack Bundle Analyzer Examples
## Install the Package
```bash
npm install --save-dev webpack-bundle-analyzer
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
// Your existing webpack config
plugins: [
new BundleAnalyzerPlugin(),
],
};
import _ from 'lodash';
const result = _.merge(object1, object2);
import merge from 'lodash/merge';
const result = merge(object1, object2);
webpack --profile --json > stats.json
npx webpack-bundle-analyzer stats.json
{
"name": "your-project-name",
"version": "1.0.0",
"scripts": {
"build": "webpack --mode production",
"analyze": "webpack --profile --json > stats.json && webpack-bundle-analyzer stats.json"
},
"devDependencies": {
"webpack": "^5.0.0",
"webpack-bundle-analyzer": "^4.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment