npm.io
3.0.2 • Published 1 week ago

rollup-plugin-stats

Licence
MIT
Version
3.0.2
Deps
0
Size
75 kB
Vulns
0
Weekly
0
Stars
1

rollup-plugin-stats

npm Socket Badge ci

Vite compatibility Rolldown compatibility Rollup compatibility

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

Install

npm install --dev rollup-plugin-stats

or

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

or

yarn add --dev rollup-plugin-stats

Configure

Vite
// 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
// 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(),
  ],
});
// 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
// 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
nvm use
Install dependencies
npm install
Prepare
npm run prepare
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

Generate vite/rollup/rolldown stats JSON file with a bundle-stats webpack supported structure.

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

Get started

Keywords