Gathering detailed insights and metrics for rollup-plugin-webpack-stats
Gathering detailed insights and metrics for rollup-plugin-webpack-stats
Gathering detailed insights and metrics for rollup-plugin-webpack-stats
Gathering detailed insights and metrics for rollup-plugin-webpack-stats
Generate rollup stats JSON file with a bundle-stats webpack supported structure.
npm install rollup-plugin-webpack-stats
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
135 Commits
2 Forks
1 Watching
5 Branches
4 Contributors
Updated on 25 Nov 2024
TypeScript (88.57%)
JavaScript (9.37%)
Shell (2.06%)
Cumulative downloads
Total Downloads
Last day
-14.1%
7,392
Compared to previous day
Last week
-0.6%
41,358
Compared to previous week
Last month
13.9%
183,263
Compared to previous month
Last year
599.9%
1,653,191
Compared to previous year
1
Generate rollup stats JSON file with a bundle-stats webpack supported structure.
1npm install --dev rollup-plugin-webpack-stats
or
1yarn add --dev rollup-plugin-webpack-stats
or
1pnpm add -D rollup-plugin-webpack-stats
1// rollup.config.js 2import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 3 4export default { 5 plugins: [ 6 // add it as the last plugin 7 webpackStatsPlugin(), 8 ], 9};
1// vite.config.js 2import { defineConfig } from 'vite'; 3import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 4 5export default defineConfig((env) => ({ 6 plugins: [ 7 // Output webpack-stats.json file 8 webpackStatsPlugin(), 9 ], 10}));
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)>
transform
- access and mutate the resulting stats after the conversion: (stats: WebpackStatsFilterd, sources: TransformSources, bundle: OutputBundle) => WebpackStatsFilterd
1// rollup.config.js 2import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 3 4module.exports = { 5 plugins: [ 6 // add it as the last plugin 7 webpackStatsPlugin({ 8 filename: 'artifacts/stats.json', 9 }), 10 ], 11};
.map
files1// rollup.config.js 2import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 3 4export default { 5 plugins: [ 6 // add it as the last plugin 7 webpackStatsPlugin({ 8 excludeAssets: /\.map$/, 9 }), 10 ], 11};
1// for the the modern and legacy outputs 2import { defineConfig } from 'vite'; 3import legacy from '@vitejs/plugin-legacy'; 4import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 5 6export default defineConfig((env) => ({ 7 build: { 8 rollupOptions: { 9 output: { 10 plugins: [ 11 // Output webpack-stats-modern.json file for the modern build 12 // Output webpack-stats-legacy.json file for the legacy build 13 // Stats are an output plugin, as plugin-legacy works by injecting 14 // an additional output, that duplicates the plugins configured here 15 webpackStatsPlugin((options) => { 16 const isLegacy = options.format === 'system'; 17 return { 18 fileName: `webpack-stats${isLegacy ? '-legacy' : '-modern'}.json`, 19 }; 20 }), 21 ], 22 }, 23 }, 24 }, 25 plugins: [ 26 legacy({ 27 /* Your legacy config here */ 28 }), 29 ], 30}));
1import { defineConfig } from 'vite'; 2import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; 3 4export default defineConfig((env) => ({ 5 build: { 6 rollupOptions: { 7 output: { 8 plugins: [ 9 webpackStatsPlugin({ 10 transform: (stats) => { 11 // Find the target chunk entry 12 const mainChunkIndex = stats.chunks?.findIndex((chunk) => chunk.names?.includes("main")); 13 14 // When the tartget chunk is found, set the initial flag to true 15 if (typeof mainChunkIndex !== 'undefined' && stats?.chunks?.[mainChunkIndex]) { 16 stats.chunks[mainChunkIndex] = { 17 ...stats.chunks[mainChunkIndex], 18 initial: true, 19 }; 20 } 21 22 // return the modified stats object 23 return stats; 24 }, 25 }), 26 ], 27 }, 28 }, 29 }, 30}));
No vulnerabilities found.
No security vulnerabilities found.