rollup-plugin-webpack-stats
Warning
Under active development
Generate rollup stats JSON file with a bundle-stats webpack supported structure.
Install
npm install --dev rollup-plugin-webpack-stats
or
yarn add --dev rollup-plugin-webpack-stats
Configure
const { webpackStats } = require('rollup-plugin-webpack-stats');
module.exports = {
plugins: [
webpackStats(),
],
};
import { defineConfig } from 'vite';
import { webpackStats } from 'rollup-plugin-webpack-stats';
export default defineConfig((env) => ({
plugins: [
webpackStats(),
],
}));
Options
fileName
- JSON stats file inside rollup/vite output directoryexcludeAssets
- 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)>
Examples
Output to a custom filename
const { webpackStats } = require('rollup-plugin-webpack-stats');
module.exports = {
plugins: [
webpackStats({
filename: 'artifacts/stats.json,
}),
],
};
Exclude .map
files
const { webpackStats } = require('rollup-plugin-webpack-stats');
module.exports = {
plugins: [
webpackStats({
excludeAssets: /\.map$/,
}),
],
};
Vite.js - multiple stats files when using plugin-legacy
import { defineConfig } from 'vite';
import legacy from '@vitejs/plugin-legacy';
import { webpackStats } from 'rollup-plugin-webpack-stats';
export default defineConfig((env) => ({
build: {
rollupOptions: {
output: {
plugins: [
webpackStats((options) => {
const isLegacy = options.format === 'system';
return {
fileName: `webpack-stats${isLegacy ? '-legacy' : '-modern'}.json`,
};
}),
],
},
},
},
plugins: [
legacy({
}),
],
}));
Resources