# rollup-plugin-stats

> Vite/Rolldown/Rollup plugin to generate bundle stats JSON file

Latest version **3.0.2** (published 2026-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-stats
pnpm add rollup-plugin-stats
yarn add rollup-plugin-stats
bun add rollup-plugin-stats
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-10-31 |
| First published | 2023-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 74.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Viorel Cojocaru |
| Maintainers | vio, relativeci-bot |
| Keywords | vite, rolldown, rollup, vite-plugin, rolldown-plugin, rollup-plugin, bundle-stats |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-stats
- Repository: https://github.com/relative-ci/rollup-plugin-stats
- Homepage: https://github.com/relative-ci/rollup-plugin-stats#readme
- Issues: https://github.com/relative-ci/rollup-plugin-stats/issues
- npm.io page: https://npm.io/package/rollup-plugin-stats

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2026-10-31
- 3.0.0-beta.4 (beta) — 2026-08-22
- 2.0.0-rc.1 (rc) — 2026-03-02
- 3.0.1 — 2026-09-28
- 3.0.0 — 2026-08-22
- 3.0.0-beta.3 — 2026-08-09
- 3.0.0-beta.2 — 2026-07-25
- 3.0.0-beta.1 — 2026-06-20
- 3.0.0-beta.0 — 2026-06-20
- 2.1.3 — 2026-05-28
- 2.1.3-beta.0 — 2026-05-02
- 2.1.2 — 2026-04-28
- 2.1.1 — 2026-04-13
- 2.1.1-beta.5 — 2026-04-12
- 2.1.1-beta.4 — 2026-04-11
- … 58 more at https://npm.io/package/rollup-plugin-stats/versions

## README

# rollup-plugin-stats

[![](https://img.shields.io/npm/v/rollup-plugin-stats.svg)](https://www.npmjs.com/package/rollup-plugin-stats)
[![npm](https://img.shields.io/npm/dm/rollup-plugin-stats)](https://www.npmjs.com/package/rollup-plugin-stats)
![](https://img.shields.io/node/v/rollup-plugin-stats.svg)
[![Socket Badge](https://socket.dev/api/badge/npm/package/rollup-plugin-stats)](https://socket.dev/npm/package/rollup-plugin-stats)
[![ci](https://github.com/relative-ci/rollup-plugin-stats/actions/workflows/ci.yml/badge.svg)](https://github.com/relative-ci/rollup-plugin-stats/actions/workflows/ci.yml)

[![Vite compatibility](https://registry.vite.dev/api/badges?package=rollup-plugin-stats&tool=vite)](https://npmx.dev/package/rollup-plugin-stats)
[![Rolldown compatibility](https://registry.vite.dev/api/badges?package=rollup-plugin-stats&tool=rolldown)](https://npmx.dev/package/rollup-plugin-stats)
[![Rollup compatibility](https://registry.vite.dev/api/badges?package=rollup-plugin-stats&tool=rollup)](https://npmx.dev/package/rollup-plugin-stats)

Vite/Rolldown/Rollup plugin to generate bundle stats JSON file

## Install

```shell
npm install --dev rollup-plugin-stats
```

or

```shell
pnpm add --save-dev rollup-plugin-stats
```

or

```shell
yarn add --dev rollup-plugin-stats
```

## Configure

### Vite

```js
// vite.config.mjs
import { defineConfig } from 'vite';
import pluginStats from 'rollup-plugin-stats';

export default defineConfig({
  // your vite config
  plugins: [
    // add it as the last plugin
    pluginStats(),
  ],
});
```

### Rollup

```js
// rollup.config.mjs
import { defineConfig } from 'rollup';
import pluginStats from 'rollup-plugin-stats';

export default defineConfig({
  // your rollup config
  plugins: [
    // add it as the last plugin
    pluginStats(),
  ],
});
```

```js
// rollup.config.js
const { defineConfig } = require('rollup');
const pluginStats = require('rollup-plugin-stats');

module.exports = defineConfig({
  // your rollup config
  plugins: [
    // add it as the last plugin
    pluginStats(),
  ],
});
```

### Rolldown

```js
// rolldown.config.js
import { defineConfig } from 'rolldown';
import pluginStats from 'rollup-plugin-stats';

export default defineConfig({
  // your rolldown config
  plugins: [
    // add it as the last plugin
    pluginStats(),
  ],
});
```

### Options

- `fileName` - the JSON filepath relative to the build folder or absolute(default: `stats.json`)
- `write` - format and write the stats to disk(default: `fs.write(filename, JSON.stringify(stats, null, 2))`)
- `stats`
  - `source` - output asset/chunk/module source (default `false`)
  - `map` - output chunk map property (default: `false`)
  - `excludeAssets` - exclude matching assets: `string | RegExp | ((filepath: string) => boolean) | Array<string | RegExp | ((filepath: string) => boolean)>`
  - `excludeModules` - exclude matching modules: `string | RegExp | ((filepath: string) => boolean) | Array<string | RegExp | ((filepath: string) => boolean)>`

## Development setup

### Use the project node version

```shell
nvm use
```

### Install dependencies

```shell
npm install
```

### Prepare

```shell
npm run prepare
```

## Related projects

### [bundle-stats](https://github.com/relative-ci/bundle-stats)

Analyze bundle stats(bundle size, assets, modules, packages) and compare the results between different builds. Support for webpack, rspack, vite, rolldown and rollup.

### [rollup-plugin-webpack-stats](https://github.com/relative-ci/rollup-plugin-webpack-stats)

Generate vite/rollup/rolldown 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).

### :cyclone: [relative-ci.com](https://relative-ci.com?utm_medium=rollup-plugin-stats)

#### Automated bundle analysis, reviews and monitoring - Quickly identify and fix bundle regressions before shipping to production.

- :crystal_ball: In-depth bundle stats analysis for every build
- :chart_with_upwards_trend: Monitor bundle stats changes and identify opportunities for optimizations
- :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-stats), [GitHub Pull Request comments](https://relative-ci.com/documentation/setup/configure/integrations/github-pull-request-comment?utm_medium=rollup-plugin-stats), [GitHub check reports](https://relative-ci.com/documentation/setup/configure/integrations/github-check-report?utm_medium=rollup-plugin-stats), or [Slack messages](https://relative-ci.com/documentation/setup/configure/integrations/slack-notification?utm_medium=rollup-plugin-stats)
- :wrench: Support for **webpack**, **vite**, **rspack**, **rollup**, **rolldown**
- :hammer: Support for all major CI services(CircleCI, GitHub Actions, Gitlab CI, Jenkins, Travis CI)
- :nut_and_bolt: Support for **npm**, **yarn** and **pnpm**; support for monorepos
- :two_hearts: [**Always free** for **Open Source**](https://relative-ci.com/open-source?utm_medium=rollup-plugin-stats)

[:rocket: Get started](https://relative-ci.com?utm_medium=rollup-plugin-stats)

---
_Source: https://npm.io/package/rollup-plugin-stats · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
