@rollup-extras/plugin-size 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -8
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ size({
|
|
|
108
108
|
gzip: true,
|
|
109
109
|
brotli: true,
|
|
110
110
|
pluginName: "my-size",
|
|
111
|
+
outputPlugin: false,
|
|
111
112
|
minify: async (fileName, code) => {
|
|
112
113
|
// your minification logic
|
|
113
114
|
return minifiedCode;
|
|
@@ -115,16 +116,34 @@ size({
|
|
|
115
116
|
});
|
|
116
117
|
```
|
|
117
118
|
|
|
119
|
+
### Output plugin usage
|
|
120
|
+
|
|
121
|
+
The plugin can also be used as an output plugin (inside `output.plugins`). Because
|
|
122
|
+
Rollup rejects input-only hooks like `buildStart` in that position, pass
|
|
123
|
+
`outputPlugin: true` to skip attaching them:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
export default {
|
|
127
|
+
input: "src/index.js",
|
|
128
|
+
output: {
|
|
129
|
+
dir: "dist",
|
|
130
|
+
format: "es",
|
|
131
|
+
plugins: [size({ outputPlugin: true })],
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
118
136
|
## Options
|
|
119
137
|
|
|
120
|
-
| Option
|
|
121
|
-
|
|
|
122
|
-
| `statsFile`
|
|
123
|
-
| `updateStats`
|
|
124
|
-
| `gzip`
|
|
125
|
-
| `brotli`
|
|
126
|
-
| `pluginName`
|
|
127
|
-
| `
|
|
138
|
+
| Option | Type | Default | Description |
|
|
139
|
+
| -------------- | ---------- | ------------------------------ | ----------------------------------------------------------------------------------------------- |
|
|
140
|
+
| `statsFile` | `string` | `'.stats.json'` | Path to the JSON stats file (relative to project root or absolute). |
|
|
141
|
+
| `updateStats` | `boolean` | `true` | Whether to overwrite the stats file with the current build data. |
|
|
142
|
+
| `gzip` | `boolean` | `true` | Report gzip-compressed sizes. |
|
|
143
|
+
| `brotli` | `boolean` | `false` | Report brotli-compressed sizes. |
|
|
144
|
+
| `pluginName` | `string` | `'@rollup-extras/plugin-size'` | Override the plugin name reported to Rollup. |
|
|
145
|
+
| `outputPlugin` | `boolean` | `false` | Set to `true` when using the plugin in `output.plugins` (see [Output plugin usage](#output-plugin-usage)). |
|
|
146
|
+
| `minify` | `function` | `undefined` | Optional async function `(fileName, code) => minifiedCode` to minify chunks before compression. |
|
|
128
147
|
|
|
129
148
|
## How it works
|
|
130
149
|
|
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
package/index.js
CHANGED
|
@@ -193,11 +193,12 @@ export default function (options) {
|
|
|
193
193
|
updateStats: true,
|
|
194
194
|
gzip: true,
|
|
195
195
|
brotli: false,
|
|
196
|
+
outputPlugin: false,
|
|
196
197
|
},
|
|
197
198
|
factories
|
|
198
199
|
);
|
|
199
200
|
|
|
200
|
-
const { pluginName, statsFile, updateStats, logger, minify: minifyFn } = normalizedOptions;
|
|
201
|
+
const { pluginName, statsFile, updateStats, outputPlugin, logger, minify: minifyFn } = normalizedOptions;
|
|
201
202
|
|
|
202
203
|
const flags = { gzip: normalizedOptions.gzip, brotli: normalizedOptions.brotli };
|
|
203
204
|
|
|
@@ -205,6 +206,14 @@ export default function (options) {
|
|
|
205
206
|
|
|
206
207
|
const instance = multiConfigPluginBase(false, pluginName, reportAndSave, onEachOutput);
|
|
207
208
|
|
|
209
|
+
if (!outputPlugin) {
|
|
210
|
+
instance.buildStart = () => {
|
|
211
|
+
currentStats.entries = undefined;
|
|
212
|
+
currentStats.chunks = undefined;
|
|
213
|
+
currentStats.assets = undefined;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
208
217
|
return instance;
|
|
209
218
|
|
|
210
219
|
async function onEachOutput(outputOptions, bundle) {
|
package/package.json
CHANGED