You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c69dae3
Browse filesBrowse the repository at this point in the historyBrowse files
feat: an empty minify list, and deleting an original alone (#743)
* feat: deleting an original takes its own file and nothing else
The asset it read goes alone, so a source map or another generator's file beside it stays, and a function decides per asset which of them to delete.
* feat: an empty minify list is nothing to minify
For an instance whose whole job is its generate. A list with none in it needs no guard where a second kind of value would, which is why false stays out.
* fix: nothing minifying salts no hash, and names no file beside itself
An instance whose whole job is its generate rewrote no bytes, so the bundle kept its own name; and a file written under the original's name has replaced it, so recording related there wrote the source back over it.
* feat: a generator names its file with a function too, and minify is typed as written
The public type said one function where the schema has taken a list or a descriptor since 5.10, and a filename function is what webpack's own getPath takes.
* docs: compressing with minifying, and without
The two shapes a compression instance is written in, now that an empty list of minimizers says the second one.
* fix: nothing minifying salts no embedded-source hash either
The tap varies a module's hash on the minimizers, so an instance with none of them renamed files it never rewrote — the same defect the chunk hash had.
* fix: delete the asset that was read, not whatever holds its name
The generators of a pass run together, so another may have written over the original first — deleting then destroys that file instead.
Copy file name to clipboardExpand all lines: .changeset/generator-compression-options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,4 @@
2
2
"minimizer-webpack-plugin": minor
3
3
---
4
4
5
-
Add `threshold`, `minRatio` and `relatedName` to an `asset` generator, and stop `minify` from taking `false`.
5
+
Add `threshold`, `minRatio` and `relatedName` to an `asset` generator, let `deleteOriginalAssets` be a function and take the original file alone, take a `filename` function, read `minify: []` as nothing to minify rather than `false`, and type what `minify` has long accepted.
Copy file name to clipboardExpand all lines: src/index.js
+55-12Lines changed: 55 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -211,9 +211,9 @@ const {
211
211
* @property {MinimizerImplementation<EXPECTED_ANY>} implementation the generator itself
212
212
* @property {MinimizerOptions<EXPECTED_ANY>=} options options for this generator, preferred over the deprecated `generatorOptions`
213
213
* @property {("import" | "asset")=} type `import` re-encodes a module as it is built, so the import that asked for it is renamed with it; `asset` writes a new file beside one already emitted
214
-
* @property {string=} filename name for the generated asset, as a webpack filename template. `asset` generators only
214
+
* @property {(string | ((pathData: EXPECTED_ANY) => string))=} filename name for the generated asset, as a webpack filename template or a function answering with one. `asset` generators only
215
215
* @property {((name: string) => boolean)=} filter decides per asset whether to generate from it, on top of `test`/`include`/`exclude`
216
-
* @property {boolean=} deleteOriginalAssets removes the asset generated from. `asset` generators only
216
+
* @property {(boolean | ((name: string) => boolean))=} deleteOriginalAssets removes the asset generated from, its own file alone — whatever its `related` names stays. Written as a function it is asked per asset. `asset` generators only
217
217
* @property {number=} threshold generate only from assets larger than this, in bytes. `asset` generators only
218
218
* @property {number=} minRatio keep the generated asset only when it is this much smaller than the one it was read from. `asset` generators only
219
219
* @property {(string | false)=} relatedName the key the generated asset is recorded under in the original's `related` info. `asset` generators only
@@ -237,8 +237,24 @@ const {
237
237
*/
238
238
239
239
/**
240
+
* One minimizer, written as an object stating how to run it.
* @property {MinimizerImplementation<T>} implementation the minimizer itself
244
+
* @property {MinimizerOptions<T>=} options options for this minimizer, preferred over the deprecated `minimizerOptions`
245
+
* @property {((name: string, info: AssetInfo) => boolean | undefined)=} filter which assets this minimizer is offered, overriding a `filter` on the function itself
246
+
*/
247
+
248
+
/**
249
+
* What `minify` may be written as: one minimizer, a list of them — empty for
0 commit comments