rollup-plugin-webpack-stats
Advanced tools
Comparing version 0.4.0 to 1.0.0-beta.0
@@ -1,21 +0,3 @@ | ||
import { Plugin, OutputOptions } from 'rollup'; | ||
import type { ExcludeFilepathOption } from './types'; | ||
import { BundleTransformOptions } from './transform'; | ||
import { webpackStats } from './plugin'; | ||
export default webpackStats; | ||
export { bundleToWebpackStats } from './transform'; | ||
interface WebpackStatsOptions extends BundleTransformOptions { | ||
/** | ||
* JSON file output fileName | ||
* default: webpack-stats.json | ||
*/ | ||
fileName?: string; | ||
/** | ||
* Exclude matching assets | ||
*/ | ||
excludeAssets?: ExcludeFilepathOption; | ||
/** | ||
* Exclude matching modules | ||
*/ | ||
excludeModules?: ExcludeFilepathOption; | ||
} | ||
type WebpackStatsOptionsOrBuilder = WebpackStatsOptions | ((outputOptions: OutputOptions) => WebpackStatsOptions); | ||
export declare const webpackStats: (options?: WebpackStatsOptionsOrBuilder) => Plugin; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var path = require('path'); | ||
@@ -144,3 +146,3 @@ var crypto = require('crypto'); | ||
exports.bundleToWebpackStats = bundleToWebpackStats; | ||
exports.webpackStats = webpackStats; | ||
exports.default = webpackStats; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "rollup-plugin-webpack-stats", | ||
"version": "0.4.0", | ||
"version": "1.0.0-beta.0", | ||
"private": false, | ||
@@ -25,3 +25,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=18" | ||
}, | ||
@@ -28,0 +28,0 @@ "scripts": { |
@@ -29,8 +29,8 @@ # rollup-plugin-webpack-stats | ||
// rollup.config.js | ||
const { webpackStats } = require('rollup-plugin-webpack-stats'); | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
module.exports = { | ||
export default { | ||
plugins: [ | ||
// add it as the last plugin | ||
webpackStats(), | ||
webpackStatsPlugin(), | ||
], | ||
@@ -43,3 +43,3 @@ }; | ||
import { defineConfig } from 'vite'; | ||
import { webpackStats } from 'rollup-plugin-webpack-stats'; | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
@@ -49,3 +49,3 @@ export default defineConfig((env) => ({ | ||
// Output webpack-stats.json file | ||
webpackStats(), | ||
webpackStatsPlugin(), | ||
], | ||
@@ -55,8 +55,46 @@ })); | ||
### Options | ||
- `fileName` - JSON stats file inside rollup/vite output directory | ||
- `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)>` | ||
### Examples | ||
#### Output to a custom filename | ||
```js | ||
// vite.config.js - using plugin-legacy, and generating a stats file | ||
// rollup.config.js | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
module.exports = { | ||
plugins: [ | ||
// add it as the last plugin | ||
webpackStatsPlugin({ | ||
filename: 'artifacts/stats.json, | ||
}), | ||
], | ||
}; | ||
``` | ||
#### Exclude `.map` files | ||
```js | ||
// rollup.config.js | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
export default { | ||
plugins: [ | ||
// add it as the last plugin | ||
webpackStatsPlugin({ | ||
excludeAssets: /\.map$/, | ||
}), | ||
], | ||
}; | ||
``` | ||
#### Vite.js - multiple stats files when using plugin-legacy | ||
```js | ||
// for the the modern and legacy outputs | ||
import { defineConfig } from 'vite'; | ||
import legacy from '@vitejs/plugin-legacy'; | ||
import { webpackStats } from 'rollup-plugin-webpack-stats'; | ||
import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | ||
@@ -72,3 +110,3 @@ export default defineConfig((env) => ({ | ||
// an additional output, that duplicates the plugins configured here | ||
webpackStats((options) => { | ||
webpackStatsPlugin((options) => { | ||
const isLegacy = options.format === 'system'; | ||
@@ -91,9 +129,2 @@ return { | ||
### Options | ||
- `fileName` - JSON stats file inside rollup/vite output directory | ||
- `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)>` | ||
## Resources | ||
@@ -100,0 +131,0 @@ |
Sorry, the diff of this file is not supported yet
18541
9
229
134