{"id":13396668,"url":"https://github.com/webpack-contrib/webpack-bundle-analyzer","last_synced_at":"2025-05-12T18:14:55.965Z","repository":{"id":37335856,"uuid":"71966177","full_name":"webpack-contrib/webpack-bundle-analyzer","owner":"webpack-contrib","description":"Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap","archived":false,"fork":false,"pushed_at":"2025-04-02T11:43:37.000Z","size":2716,"stargazers_count":12634,"open_issues_count":31,"forks_count":493,"subscribers_count":97,"default_branch":"master","last_synced_at":"2025-05-12T18:14:40.546Z","etag":null,"topics":["analyze","bundle","chart","interactive","size","treemap","webpack","webpack-bundle-analyzer"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"webpack"}},"created_at":"2016-10-26T04:24:35.000Z","updated_at":"2025-05-11T08:26:11.000Z","dependencies_parsed_at":"2023-02-09T03:00:35.525Z","dependency_job_id":"0cac2340-3b64-4b36-86ff-0e93a4b204e8","html_url":"https://github.com/webpack-contrib/webpack-bundle-analyzer","commit_stats":{"total_commits":540,"total_committers":75,"mean_commits":7.2,"dds":0.5388888888888889,"last_synced_commit":"f8d4711d7670ffa9fae11cd34787cc45c538f9bb"},"previous_names":["th0r/webpack-bundle-analyzer"],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fwebpack-bundle-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fwebpack-bundle-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fwebpack-bundle-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fwebpack-bundle-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/webpack-bundle-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253795161,"owners_count":21965487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analyze","bundle","chart","interactive","size","treemap","webpack","webpack-bundle-analyzer"],"created_at":"2024-07-30T18:00:59.578Z","updated_at":"2025-05-12T18:14:55.946Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![downloads][downloads]][downloads-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eWebpack Bundle Analyzer\u003c/h1\u003e\n  \u003cp\u003eVisualize size of webpack output files with an interactive zoomable treemap.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\n# NPM\nnpm install --save-dev webpack-bundle-analyzer\n# Yarn\nyarn add -D webpack-bundle-analyzer\n```\n\n\u003ch2 align=\"center\"\u003eUsage (as a plugin)\u003c/h2\u003e\n\n```js\nconst BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;\n\nmodule.exports = {\n  plugins: [\n    new BundleAnalyzerPlugin()\n  ]\n}\n```\n\nIt will create an interactive treemap visualization of the contents of all your bundles.\n\n![webpack bundle analyzer zoomable treemap](https://cloud.githubusercontent.com/assets/302213/20628702/93f72404-b338-11e6-92d4-9a365550a701.gif)\n\nThis module will help you:\n\n1. Realize what's *really* inside your bundle\n2. Find out what modules make up the most of its size\n3. Find modules that got there by mistake\n4. Optimize it!\n\nAnd the best thing is it supports minified bundles! It parses them to get real size of bundled modules.\nAnd it also shows their gzipped sizes!\n\n\u003ch2 align=\"center\"\u003eOptions (for plugin)\u003c/h2\u003e\n\n```js\nnew BundleAnalyzerPlugin(options?: object)\n```\n\n|Name|Type|Description|\n|:--:|:--:|:----------|\n|**`analyzerMode`**|One of: `server`, `static`, `json`, `disabled`|Default: `server`. In `server` mode analyzer will start HTTP server to show bundle report. In `static` mode single HTML file with bundle report will be generated. In `json` mode single JSON file with bundle report will be generated. In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`. |\n|**`analyzerHost`**|`{String}`|Default: `127.0.0.1`. Host that will be used in `server` mode to start HTTP server.|\n|**`analyzerPort`**|`{Number}` or `auto`|Default: `8888`. Port that will be used in `server` mode to start HTTP server. If `analyzerPort` is `auto`, the operating system will assign an arbitrary unused port |\n|**`analyzerUrl`**|`{Function}` called with `{ listenHost: string, listenHost: string, boundAddress: server.address}`. [server.address comes from Node.js](https://nodejs.org/api/net.html#serveraddress)| Default: `http://${listenHost}:${boundAddress.port}`. The URL printed to console with server mode.|\n|**`reportFilename`**|`{String}`|Default: `report.html`. Path to bundle report file that will be generated in `static` mode. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|\n|**`reportTitle`**|`{String\\|function}`|Default: function that returns pretty printed current date and time. Content of the HTML `title` element; or a function of the form `() =\u003e string` that provides the content.|\n|**`defaultSizes`**|One of: `stat`, `parsed`, `gzip`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|\n|**`openAnalyzer`**|`{Boolean}`|Default: `true`. Automatically open report in default browser.|\n|**`generateStatsFile`**|`{Boolean}`|Default: `false`. If `true`, webpack stats JSON file will be generated in bundle output directory|\n|**`statsFilename`**|`{String}`|Default: `stats.json`. Name of webpack stats JSON file that will be generated if `generateStatsFile` is `true`. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|\n|**`statsOptions`**|`null` or `{Object}`|Default: `null`. Options for `stats.toJson()` method. For example you can exclude sources of your modules from stats file with `source: false` option. [See more options here](https://webpack.js.org/configuration/stats/). |\n|**`excludeAssets`**|`{null\\|pattern\\|pattern[]}` where `pattern` equals to `{String\\|RegExp\\|function}`|Default: `null`. Patterns that will be used to match against asset names to exclude them from the report. If pattern is a string it will be converted to RegExp via `new RegExp(str)`. If pattern is a function it should have the following signature `(assetName: string) =\u003e boolean` and should return `true` to *exclude* matching asset. If multiple patterns are provided asset should match at least one of them to be excluded. |\n|**`logLevel`**|One of: `info`, `warn`, `error`, `silent`|Default: `info`. Used to control how much details the plugin outputs.|\n\n\u003ch2 align=\"center\"\u003eUsage (as a CLI utility)\u003c/h2\u003e\n\nYou can analyze an existing bundle if you have a webpack stats JSON file.\n\nYou can generate it using `BundleAnalyzerPlugin` with `generateStatsFile` option set to `true` or with this simple\ncommand:\n\n```bash\nwebpack --profile --json \u003e stats.json\n```\n\nIf you're on Windows and using PowerShell, you can generate the stats file with this command to [avoid BOM issues](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/47):\n\n```\nwebpack --profile --json | Out-file 'stats.json' -Encoding OEM\n```\n\nThen you can run the CLI tool.\n\n```\nwebpack-bundle-analyzer bundle/output/path/stats.json\n```\n\n\u003ch2 align=\"center\"\u003eOptions (for CLI)\u003c/h2\u003e\n\n```bash\nwebpack-bundle-analyzer \u003cbundleStatsFile\u003e [bundleDir] [options]\n```\n\nArguments are documented below:\n\n### `bundleStatsFile`\n\nPath to webpack stats JSON file\n\n### `bundleDir`\n\nDirectory containing all generated bundles.\n\n### `options`\n\n```\n  -V, --version               output the version number\n  -m, --mode \u003cmode\u003e           Analyzer mode. Should be `server`, `static` or `json`.\n                              In `server` mode analyzer will start HTTP server to show bundle report.\n                              In `static` mode single HTML file with bundle report will be generated.\n                              In `json` mode single JSON file with bundle report will be generated. (default: server)\n  -h, --host \u003chost\u003e           Host that will be used in `server` mode to start HTTP server. (default: 127.0.0.1)\n  -p, --port \u003cn\u003e              Port that will be used in `server` mode to start HTTP server. Should be a number or `auto` (default: 8888)\n  -r, --report \u003cfile\u003e         Path to bundle report file that will be generated in `static` mode. (default: report.html)\n  -t, --title \u003ctitle\u003e         String to use in title element of html report. (default: pretty printed current date)\n  -s, --default-sizes \u003ctype\u003e  Module sizes to show in treemap by default.\n                              Possible values: stat, parsed, gzip (default: parsed)\n  -O, --no-open               Don't open report in default browser automatically.\n  -e, --exclude \u003cregexp\u003e      Assets that should be excluded from the report.\n                              Can be specified multiple times.\n  -l, --log-level \u003clevel\u003e     Log level.\n                              Possible values: debug, info, warn, error, silent (default: info)\n  -h, --help                  output usage information\n```\n\n\u003ch2 align=\"center\" id=\"size-definitions\"\u003eSize definitions\u003c/h2\u003e\n\nwebpack-bundle-analyzer reports three values for sizes. `defaultSizes` can be used to control which of these is shown by default. The different reported sizes are:\n\n### `stat`\n\nThis is the \"input\" size of your files, before any transformations like\nminification.\n\nIt is called \"stat size\" because it's obtained from Webpack's\n[stats object](https://webpack.js.org/configuration/stats/).\n\n### `parsed`\n\nThis is the \"output\" size of your files. If you're using a Webpack plugin such\nas Uglify, then this value will reflect the minified size of your code.\n\n### `gzip`\n\nThis is the size of running the parsed bundles/modules through gzip compression.\n\n\u003ch2 align=\"center\"\u003eSelecting Which Chunks to Display\u003c/h2\u003e\n\nWhen opened, the report displays all of the Webpack chunks for your project. It's possible to filter to a more specific list of chunks by using the sidebar or the chunk context menu.\n\n### Sidebar\n\nThe Sidebar Menu can be opened by clicking the `\u003e` button at the top left of the report. You can select or deselect chunks to display under the \"Show chunks\" heading there.\n\n### Chunk Context Menu\n\nThe Chunk Context Menu can be opened by right-clicking or `Ctrl`-clicking on a specific chunk in the report. It provides the following options:\n\n * **Hide chunk:** Hides the selected chunk\n * **Hide all other chunks:** Hides all chunks besides the selected one\n * **Show all chunks:** Un-hides any hidden chunks, returning the report to its initial, unfiltered view\n\n\u003ch2 align=\"center\"\u003eTroubleshooting\u003c/h2\u003e\n\n### I don't see `gzip` or `parsed` sizes, it only shows `stat` size\n\nIt happens when `webpack-bundle-analyzer` analyzes files that don't actually exist in your file system, for example when you work with `webpack-dev-server` that keeps all the files in RAM. If you use `webpack-bundle-analyzer` as a plugin you won't get any errors, however if you run it via CLI you get the error message in terminal:\n```\nError parsing bundle asset \"your_bundle_name.bundle.js\": no such file\nNo bundles were parsed. Analyzer will show only original module sizes from stats file.\n```\nTo get more information about it you can read [issue #147](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/147).\n\n\u003ch2 align=\"center\"\u003eOther tools\u003c/h2\u003e\n\n- [Statoscope](https://github.com/smelukov/statoscope/blob/master/packages/ui-webpack/README.md) - Webpack bundle analyzing tool to find out why a certain module was bundled (and more features, including interactive treemap)\n\n\u003ch2 align=\"center\"\u003eMaintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/302213?v=4\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/th0r\"\u003eYuriy Grunin\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/482561?v=4\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/valscion\"\u003eVesa Laakso\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\n[npm]: https://img.shields.io/npm/v/webpack-bundle-analyzer.svg\n[npm-url]: https://npmjs.com/package/webpack-bundle-analyzer\n\n[node]: https://img.shields.io/node/v/webpack-bundle-analyzer.svg\n[node-url]: https://nodejs.org\n\n[tests]: https://github.com/webpack-contrib/webpack-bundle-analyzer/actions/workflows/main.yml/badge.svg\n[tests-url]: https://github.com/webpack-contrib/webpack-bundle-analyzer/actions/workflows/main.yml\n\n[downloads]: https://img.shields.io/npm/dt/webpack-bundle-analyzer.svg\n[downloads-url]: https://npmjs.com/package/webpack-bundle-analyzer\n\n\u003ch2 align=\"center\"\u003eContributing\u003c/h2\u003e\n\nCheck out [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on contributing :tada:\n","funding_links":["https://opencollective.com/webpack"],"categories":["webpack","Webpack","JavaScript","Tools",":mortar_board: 搜罗一切酷酷的东西","module","Plugins","打包工具","Compile \u0026 Pack","前端开发框架及项目","webpack loader plugin","Advantage","Bundle Analyzer","Tools to analyze bundle size","Bundle Analyzers"],"sub_categories":["Bundle Analyzers","Rspack Plugins","webpack 辅助工具、Loader 和插件","Webpack","其他_文本生成、文本对话","Meetups"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fwebpack-bundle-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Fwebpack-bundle-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fwebpack-bundle-analyzer/lists"}