rollup-plugin-webpack-stats
Advanced tools
Comparing version 1.0.5-beta.0 to 1.1.0-beta.0
@@ -47,3 +47,7 @@ import type { OutputBundle } from 'rollup'; | ||
excludeModules?: ExcludeFilepathOption; | ||
/** | ||
* Transform function to access and mutate the resulting stats after the convertion | ||
*/ | ||
transform?: (stats: WebpackStatsFiltered) => WebpackStatsFiltered; | ||
}; | ||
export declare const bundleToWebpackStats: (bundle: OutputBundle, pluginOptions?: BundleTransformOptions) => WebpackStatsFiltered; |
{ | ||
"name": "rollup-plugin-webpack-stats", | ||
"version": "1.0.5-beta.0", | ||
"version": "1.1.0-beta.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -61,2 +61,3 @@ # rollup-plugin-webpack-stats | ||
- `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) => WebpackStatsFilterd` | ||
@@ -129,2 +130,36 @@ ### Examples | ||
#### Vite.js - update initial flag for chunks where the inital flag is incorrectly set to false | ||
```js | ||
import { defineConfig } from 'vite'; | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
export default defineConfig((env) => ({ | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
plugins: [ | ||
webpackStatsPlugin({ | ||
transform: (stats) => { | ||
// Find the target chunk entry | ||
const mainChunkIndex = stats.chunks?.findIndex((chunk) => chunk.names?.includes("main")); | ||
// When the tartget chunk is found, set the initial flag to true | ||
if (typeof mainChunkIndex !== 'undefined' && stats?.chunks?.[mainChunkIndex]) { | ||
stats.chunks[mainChunkIndex] = { | ||
...stats.chunks[mainChunkIndex], | ||
initial: true, | ||
}; | ||
} | ||
// return the modified stats object | ||
return stats; | ||
}, | ||
}), | ||
], | ||
}, | ||
}, | ||
}, | ||
})); | ||
``` | ||
## Resources | ||
@@ -131,0 +166,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30982
395
173