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 6e14d17
Browse filesBrowse the repository at this point in the historyBrowse files
feat(css): add customMedia and customSelectors minimizer options
Split resolveCustomAtRules into one option per at-rule, matching
module.parser.css.customMedia/customSelectors; the old option is
deprecated and turns on each one that is not set.
* Resolve the `@custom-media` at-rule: write the query a name stands for wherever a condition asks for it, and drop the rule that named it. `@custom-media --wide (width>400px)` with `@media (--wide)` becomes `@media (width>400px)`. Off by default: `module.parser.css.customMedia` already resolves it in every stylesheet webpack parses, so this is for a `.css` asset that reached the minimizer without being parsed — one emitted by `asset/resource` or copied in. Every rule is read first, so a name resolves wherever its rule stands, the last rule stating it holds, and one name may be read through another; names that read each other in a cycle stand for nothing and are left as written.
3132
+
* @since 5.112.0
3133
+
*/
3134
+
customMedia?: boolean;
3135
+
/**
3136
+
* Resolve the `@custom-selector` at-rule: write the selector list a name stands for as `:is(…)` wherever a selector asks for it, and drop the rule that named it. `@custom-selector :--heading h1, h2` with `:--heading` becomes `:is(h1, h2)`. Off by default, for the reason `customMedia` is: `module.parser.css.customSelectors` already resolves it in every stylesheet webpack parses. Rules are read as `customMedia` reads them, and a name is written out only where the target reads `:is()`.
3137
+
* @since 5.112.0
3138
+
*/
3139
+
customSelectors?: boolean;
3130
3140
/**
3131
3141
* Drop a declaration a later one in the same block overrides even where nothing states that the target can read the later value. Off by default. With a `browserslist` target this is already done wherever every browser it names is known to read the later value, so the option only widens the case where no target is selected and there are no engines to name — which is what csso and cssnano do unconditionally. What it gives up is the fallback pair: `color:#c65d06;color:lab(50% 100 -100)` loses the hex, so an engine that cannot read `lab()` is left with nothing. A selection naming a browser the compat tables do not cover is still answered for the whole of it rather than by this option, since naming a browser states a target the option does not override.
* Resolve the `@custom-media` and `@custom-selector` at-rules: write the query or the selector list a name stands for wherever one asks for it, and drop the rule that named it. `@custom-media --wide (width>400px)` with `@media (--wide)` becomes `@media (width>400px)`, and `@custom-selector :--heading h1, h2` with `:--heading` becomes `:is(h1, h2)`. Off until asked for: `module.parser.css.customMedia` and `module.parser.css.customSelectors` already resolve both in every stylesheet webpack parses, so this is for a `.css` asset that reached the minimizer without being parsed — one emitted by `asset/resource` or copied in. Only a name stated before the rule asking for it is written out — the rules are read in the order they are written — and a rule naming one this has not come to is left as the author had it. A selector list is written as `:is(…)`, so a name is substituted only where the target reads `:is()`.
3196
+
* Deprecated in favor of `customMedia` and `customSelectors`: it turns on each of the two that is not set. Resolve the `@custom-media` and `@custom-selector` at-rules.
* @property {boolean=} foldCase write a name that matches ASCII case-insensitively — an at-rule, property, pseudo, function, unit or keyword — in lowercase
4197
4197
* @property {boolean=} rewriteEscapes write an escaped identifier the shortest way that names it, wherever it stands
4198
4198
* @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
4199
-
* @property {boolean=} resolveCustomAtRules write the query or selector list a `@custom-media` / `@custom-selector` names wherever one asks for it, and drop the rule that named it
4199
+
* @property {boolean=} customMedia write the query a `@custom-media` names wherever a condition asks for it, and drop the rule that named it
4200
+
* @property {boolean=} customSelectors write the selector list a `@custom-selector` names as `:is(…)` wherever a selector asks for it, and drop the rule that named it
4201
+
* @property {boolean=} resolveCustomAtRules turn on `customMedia` and `customSelectors`, each where it is not set
4200
4202
* @property {boolean=} mergeLonghands write a family of longhands as the one shorthand that sets them
4201
4203
* @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
4202
4204
* @property {boolean=} normalizeQuotes normalize a string's, `url()`'s, font family's and attribute value's quoting
Copy file name to clipboardExpand all lines: schemas/WebpackOptions.json
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4053,6 +4053,16 @@
4053
4053
"type": "boolean",
4054
4054
"added": "5.110.0"
4055
4055
},
4056
+
"customMedia": {
4057
+
"description": "Resolve the `@custom-media` at-rule: write the query a name stands for wherever a condition asks for it, and drop the rule that named it. `@custom-media --wide (width>400px)` with `@media (--wide)` becomes `@media (width>400px)`. Off by default: `module.parser.css.customMedia` already resolves it in every stylesheet webpack parses, so this is for a `.css` asset that reached the minimizer without being parsed — one emitted by `asset/resource` or copied in. Every rule is read first, so a name resolves wherever its rule stands, the last rule stating it holds, and one name may be read through another; names that read each other in a cycle stand for nothing and are left as written.",
4058
+
"type": "boolean",
4059
+
"added": "5.112.0"
4060
+
},
4061
+
"customSelectors": {
4062
+
"description": "Resolve the `@custom-selector` at-rule: write the selector list a name stands for as `:is(…)` wherever a selector asks for it, and drop the rule that named it. `@custom-selector :--heading h1, h2` with `:--heading` becomes `:is(h1, h2)`. Off by default, for the reason `customMedia` is: `module.parser.css.customSelectors` already resolves it in every stylesheet webpack parses. Rules are read as `customMedia` reads them, and a name is written out only where the target reads `:is()`.",
4063
+
"type": "boolean",
4064
+
"added": "5.112.0"
4065
+
},
4056
4066
"dropOverriddenDeclarations": {
4057
4067
"description": "Drop a declaration a later one in the same block overrides even where nothing states that the target can read the later value. Off by default. With a `browserslist` target this is already done wherever every browser it names is known to read the later value, so the option only widens the case where no target is selected and there are no engines to name — which is what csso and cssnano do unconditionally. What it gives up is the fallback pair: `color:#c65d06;color:lab(50% 100 -100)` loses the hex, so an engine that cannot read `lab()` is left with nothing. A selection naming a browser the compat tables do not cover is still answered for the whole of it rather than by this option, since naming a browser states a target the option does not override.",
4058
4068
"type": "boolean",
@@ -4109,8 +4119,9 @@
4109
4119
"added": "5.110.0"
4110
4120
},
4111
4121
"resolveCustomAtRules": {
4112
-
"description": "Resolve the `@custom-media` and `@custom-selector` at-rules: write the query or the selector list a name stands for wherever one asks for it, and drop the rule that named it. `@custom-media --wide (width>400px)` with `@media (--wide)` becomes `@media (width>400px)`, and `@custom-selector :--heading h1, h2` with `:--heading` becomes `:is(h1, h2)`. Off until asked for: `module.parser.css.customMedia` and `module.parser.css.customSelectors` already resolve both in every stylesheet webpack parses, so this is for a `.css` asset that reached the minimizer without being parsed — one emitted by `asset/resource` or copied in. Only a name stated before the rule asking for it is written out — the rules are read in the order they are written — and a rule naming one this has not come to is left as the author had it. A selector list is written as `:is(…)`, so a name is substituted only where the target reads `:is()`.",
4122
+
"description": "Deprecated in favor of `customMedia` and `customSelectors`: it turns on each of the two that is not set. Resolve the `@custom-media` and `@custom-selector` at-rules.",
0 commit comments