{"id":20021112,"url":"https://github.com/relative-ci/rollup-plugin-webpack-stats","last_synced_at":"2026-03-03T01:17:01.439Z","repository":{"id":65228018,"uuid":"586509485","full_name":"relative-ci/rollup-plugin-webpack-stats","owner":"relative-ci","description":"Generate rollup stats JSON file with a bundle-stats webpack supported structure.","archived":false,"fork":false,"pushed_at":"2025-04-29T03:01:59.000Z","size":1034,"stargazers_count":6,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T04:28:05.818Z","etag":null,"topics":["bundle-stats","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":"https://relative-ci.com/documentation/guides/bundle-stats/vite","language":"TypeScript","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/relative-ci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-01-08T12:03:19.000Z","updated_at":"2025-04-22T10:56:59.000Z","dependencies_parsed_at":"2023-08-27T11:26:59.300Z","dependency_job_id":"95164a89-72fa-4de5-b22f-5325fd295014","html_url":"https://github.com/relative-ci/rollup-plugin-webpack-stats","commit_stats":null,"previous_names":["relative-ci/rollup-plugin-webpack-stats","vio/rollup-plugin-webpack-stats"],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relative-ci%2Frollup-plugin-webpack-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relative-ci%2Frollup-plugin-webpack-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relative-ci%2Frollup-plugin-webpack-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/relative-ci%2Frollup-plugin-webpack-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/relative-ci","download_url":"https://codeload.github.com/relative-ci/rollup-plugin-webpack-stats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252422966,"owners_count":21745523,"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":["bundle-stats","rollup","rollup-plugin"],"created_at":"2024-11-13T08:35:31.582Z","updated_at":"2026-01-04T12:12:49.516Z","avatar_url":"https://github.com/relative-ci.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rollup-plugin-webpack-stats\n\n[![](https://img.shields.io/npm/v/rollup-plugin-webpack-stats.svg)](https://www.npmjs.com/package/rollup-plugin-webpack-stats)\n[![](https://img.shields.io/npm/dm/rollup-plugin-webpack-stats.svg)](https://www.npmjs.com/package/rollup-plugin-webpack-stats)\n![](https://img.shields.io/node/v/rollup-plugin-webpack-stats.svg)\n[![ci](https://github.com/relative-ci/rollup-plugin-webpack-stats/actions/workflows/ci.yml/badge.svg)](https://github.com/relative-ci/rollup-plugin-webpack-stats/actions/workflows/ci.yml)\n[![Socket Badge](https://socket.dev/api/badge/npm/package/rollup-plugin-webpack-stats)](https://socket.dev/npm/package/rollup-plugin-webpack-stats)\n\nGenerate rollup stats JSON file with a [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli) webpack [supported structure](https://github.com/relative-ci/bundle-stats/blob/master/packages/plugin-webpack-filter/src/index.ts).\n\n## Install\n\n```shell\nnpm install --dev rollup-plugin-webpack-stats\n```\n\nor\n\n```shell\nyarn add --dev rollup-plugin-webpack-stats\n```\n\nor\n\n```shell\npnpm add -D rollup-plugin-webpack-stats\n```\n\n## Configure\n\n```js\n// rollup.config.js\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nexport default {\n  plugins: [\n    // add it as the last plugin\n    webpackStatsPlugin(),\n  ],\n};\n```\n\n```js\n// vite.config.js\nimport { defineConfig } from 'vite';\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nexport default defineConfig((env) =\u003e ({\n  plugins: [\n    // Output webpack-stats.json file\n    webpackStatsPlugin(),\n  ],\n}));\n```\n\n### Options\n\n- `fileName` - the JSON filepath relative to the build folder or absolute(default: `webpack-stats.json`)\n- `transform` - access and mutate the resulting stats after the conversion: `(stats: WebpackStatsFilterd, sources: TransformSources, bundle: OutputBundle) =\u003e WebpackStatsFilterd`\n- `moduleOriginalSize` - extract module original size or rendered size (default: `false`)\n- `write` - format and write the stats to disk(default: `fs.write(filename, JSON.stringify(stats, null, 2))`)\n- rollup stats options ([rollup-plugin-stats](https://github.com/relative-ci/rollup-plugin-stats#options))\n    - `excludeAssets` - exclude matching assets: `string | RegExp | ((filepath: string) =\u003e boolean) | Array\u003cstring | RegExp | ((filepath: string) =\u003e boolean)\u003e`\n    - `excludeModules` - exclude matching modules: `string | RegExp | ((filepath: string) =\u003e boolean) | Array\u003cstring | RegExp | ((filepath: string) =\u003e boolean)\u003e`\n\n### Examples\n\n#### Output to a custom filename\n```js\n// rollup.config.js\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nmodule.exports = {\n  plugins: [\n    // add it as the last plugin\n    webpackStatsPlugin({\n      filename: 'artifacts/stats.json',\n    }),\n  ],\n};\n```\n\n#### Exclude `.map` files\n```js\n// rollup.config.js\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nexport default {\n  plugins: [\n    // add it as the last plugin\n    webpackStatsPlugin({\n      excludeAssets: /\\.map$/,\n    }),\n  ],\n};\n```\n\n#### Vite.js - multiple stats files when using plugin-legacy\n```js\n// for the the modern and legacy outputs\nimport { defineConfig } from 'vite';\nimport legacy from '@vitejs/plugin-legacy';\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nexport default defineConfig((env) =\u003e ({\n  build: {\n    rollupOptions: {\n      output: {\n        plugins: [\n          // Output webpack-stats-modern.json file for the modern build\n          // Output webpack-stats-legacy.json file for the legacy build\n          // Stats are an output plugin, as plugin-legacy works by injecting\n          // an additional output, that duplicates the plugins configured here\n          webpackStatsPlugin((options) =\u003e {\n            const isLegacy = options.format === 'system';\n            return {\n              fileName: `webpack-stats${isLegacy ? '-legacy' : '-modern'}.json`,\n            };\n          }),\n        ],\n      },\n    },\n  },\n  plugins: [\n    legacy({\n      /* Your legacy config here */\n    }),\n  ],\n}));\n```\n\n#### Vite.js - update initial flag for chunks where the inital flag is incorrectly set to false\n```js\nimport { defineConfig } from 'vite';\nimport webpackStatsPlugin from 'rollup-plugin-webpack-stats';\n\nexport default defineConfig((env) =\u003e ({\n  build: {\n    rollupOptions: {\n      output: {\n        plugins: [\n          webpackStatsPlugin({\n            transform: (stats) =\u003e {\n              // Find the target chunk entry\n              const mainChunkIndex = stats.chunks?.findIndex((chunk) =\u003e chunk.names?.includes(\"main\"));\n\n              // When the tartget chunk is found, set the initial flag to true\n              if (typeof mainChunkIndex !== 'undefined' \u0026\u0026 stats?.chunks?.[mainChunkIndex]) {\n                stats.chunks[mainChunkIndex] = {\n                  ...stats.chunks[mainChunkIndex],\n                  initial: true,\n                };\n              }\n\n              // return the modified stats object\n              return stats;\n            },\n          }),\n        ],\n      },\n    },\n  },\n}));\n```\n\n## Resources\n\n- [Vite - Using plugins](https://vitejs.dev/guide/using-plugins)\n- [Rollup - Using plugins](https://rollupjs.org/tutorial/#using-plugins)\n- [RelativeCI - Vite configuration for better bundle monitoring](https://relative-ci.com/documentation/guides/vite-config)\n\n## [@relative-ci/agent](https://github.com/relative-ci/agent) examples\n\n- [example-vite-github-action](https://github.com/relative-ci/example-vite-github-action)\n- [example-vite-cli-github-action](https://github.com/relative-ci/example-vite-cli-github-action)\n\n## Related projects\n\n### [bundle-stats](https://github.com/relative-ci/bundle-stats)\n\nAnalyze bundle stats(bundle size, assets, modules, packages) and compare the results between different builds. Support for webpack, rspack, vite, rolldown and rollup.\n\n### [rollup-plugin-stats](https://github.com/relative-ci/rollup-webpack-stats)\n\nOutput vite/rollup/rolldown stats.\n\n### :cyclone: [relative-ci.com](https://relative-ci.com?utm_medium=rollup-plugin-webpack-stats)\n\n#### Automated bundle analysis, reviews and monitoring - Quickly identify and fix bundle regressions before shipping to production.\n\n- :crystal_ball: In-depth bundle stats analysis for every build\n- :chart_with_upwards_trend: Monitor bundle stats changes and identify opportunities for optimizations\n- :bell: Quick feedback with [rule based automated review flow](https://relative-ci.com/documentation/setup/configure/integrations/github-commit-status-review?utm_medium=rollup-plugin-webpack-stats), [GitHub Pull Request comments](https://relative-ci.com/documentation/setup/configure/integrations/github-pull-request-comment?utm_medium=rollup-plugin-webpack-stats), [GitHub check reports](https://relative-ci.com/documentation/setup/configure/integrations/github-check-report?utm_medium=rollup-plugin-webpack-stats), or [Slack messages](https://relative-ci.com/documentation/setup/configure/integrations/slack-notification?utm_medium=rollup-plugin-webpack-stats)\n- :wrench: Support for **webpack**, **vite**, **rspack**, **rollup**, **rolldown**\n- :hammer: Support for all major CI services(CircleCI, GitHub Actions, Gitlab CI, Jenkins, Travis CI)\n- :nut_and_bolt: Support for **npm**, **yarn** and **pnpm**; support for monorepos\n- :two_hearts: [**Always free** for **Open Source**](https://relative-ci.com/open-source?utm_medium=rollup-plugin-webpack-stats)\n\n[:rocket: Get started](https://relative-ci.com?utm_medium=rollup-plugin-webpack-stats)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelative-ci%2Frollup-plugin-webpack-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelative-ci%2Frollup-plugin-webpack-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelative-ci%2Frollup-plugin-webpack-stats/lists"}