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 ffdf76d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(css): write a fallback for a color the browserslist target cannot read
A `lab()` / `lch()` / `oklab()` / `oklch()` / `hwb()` color only converts to hex
where the two agree exactly, so a target reading none of those functions was
left with a declaration it drops. The color each names is now written as an
extra declaration before it — `color:#c65d06;color:oklch(59.686% .15619
49.7694)` — so the modern spelling still reaches the engines that read it while
the others get a color.
The two refusals the conversion makes are about replacing the function, not
standing before it: a fallback is only ever read where there is no better
answer, so it clips into the sRGB gamut and takes whichever byte rounding picks,
and writes an `rgba()` where the target has no hex alpha either.
Nothing is written where the author already set the property earlier in the
block, where the color holds a relative reference or a call this cannot fold, or
where the fallback would still name a function the target cannot read — the
engine drops such a fallback exactly as it drops the declaration it precedes.
`optimization.minimize.css.colorFallbacks` turns it off.
* Write a color the `browserslist` target cannot read as an extra declaration before the one naming it, in a spelling it does read: `color: oklch(59.686% 0.15619 49.7694)` is written as `color: #c65d06` and then the `oklch()` itself, so an engine reading neither the Lab family nor `hwb()` is left with a color rather than with nothing. The fallback is that color clipped into the sRGB gamut and rounded, which the declaration standing after it corrects wherever it is read. Nothing is written where the author already set the property earlier in the same block, where the color holds a substitution or a relative reference this cannot fold, or where the fallback would still name a function the target cannot read. On by default, and only in effect for a `browserslist` target — any other target names no browsers to answer for.
2418
+
* @since 5.111.0
2419
+
*/
2420
+
colorFallbacks?: boolean;
2416
2421
/**
2417
2422
* Which comments survive. `"some"`, the default, keeps a `/*!` banner and a comment annotated `@license` or `@preserve`; `true` (or `"all"`) keeps every comment and `false` keeps none; a string is read as a regular expression source, and it, a `RegExp` or a `(comment) => boolean` predicate is asked about each comment's own text and keeps the ones it accepts — standing in for the default rule rather than beside it, as terser's `format.comments` does, so a pattern that names nothing else drops the ones `"some"` would have kept. A `/*#` source-map pragma is a link rather than a comment, so `"some"` and `"all"` keep it; `false`, a pattern or a predicate decides it like any other. A predicate is handed to the minimizer's worker pool as source, so it must not close over anything.
* What the minifying printer may rewrite. Every entry is on unless it is
4014
4021
* `false`, so a document one transform breaks can still be minified by the rest.
4015
4022
* @typedef {object} CssTransformOptions
4023
+
* @property {boolean=} colorFallbacks write a color the target cannot read as an extra declaration before it, in a spelling it does read
4016
4024
* @property {(boolean | "all" | "some" | string | RegExp | ((comment: string) => boolean))=} comments which comments survive: `"some"` (the default) the ones that carry something, `true` / `"all"` every one, `false` none, or the ones a pattern matches / a predicate accepts, over the comment's own text
4017
4025
* @property {boolean=} mergeLonghands write a family of longhands as the one shorthand that sets them
4018
4026
* @property {boolean=} mergeRules join rules that print the same block, at-rules that share a prelude, and a named `@layer` block a later sibling opens again
Copy file name to clipboardExpand all lines: schemas/WebpackOptions.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3731,6 +3731,11 @@
3731
3731
"type": "object",
3732
3732
"additionalProperties": false,
3733
3733
"properties": {
3734
+
"colorFallbacks": {
3735
+
"description": "Write a color the `browserslist` target cannot read as an extra declaration before the one naming it, in a spelling it does read: `color: oklch(59.686% 0.15619 49.7694)` is written as `color: #c65d06` and then the `oklch()` itself, so an engine reading neither the Lab family nor `hwb()` is left with a color rather than with nothing. The fallback is that color clipped into the sRGB gamut and rounded, which the declaration standing after it corrects wherever it is read. Nothing is written where the author already set the property earlier in the same block, where the color holds a substitution or a relative reference this cannot fold, or where the fallback would still name a function the target cannot read. On by default, and only in effect for a `browserslist` target — any other target names no browsers to answer for.",
3736
+
"type": "boolean",
3737
+
"added": "5.111.0"
3738
+
},
3734
3739
"comments": {
3735
3740
"description": "Which comments survive. `\"some\"`, the default, keeps a `/*!` banner and a comment annotated `@license` or `@preserve`; `true` (or `\"all\"`) keeps every comment and `false` keeps none; a string is read as a regular expression source, and it, a `RegExp` or a `(comment) => boolean` predicate is asked about each comment's own text and keeps the ones it accepts — standing in for the default rule rather than beside it, as terser's `format.comments` does, so a pattern that names nothing else drops the ones `\"some\"` would have kept. A `/*#` source-map pragma is a link rather than a comment, so `\"some\"` and `\"all\"` keep it; `false`, a pattern or a predicate decides it like any other. A predicate is handed to the minimizer's worker pool as source, so it must not close over anything.",
0 commit comments