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 19d3cc6
Browse filesBrowse the repository at this point in the historyBrowse files
A .css asset served as UTF-8 needs no @charset "UTF-8" to be read so; the
option states that, so the minimizer writes none and still writes an escaped
character past U+FFFF as the character.
* State that each `.css` asset is read as UTF-8 wherever it is served, so the minimizer writes no `@charset "UTF-8"` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's `content: "\F0A86"`) as the character itself, as it does once that `@charset` is written. Off by default, because the statement must be true: a stylesheet with no `@charset` is read in the encoding the server's `Content-Type` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.
3113
+
* @since 5.112.0
3114
+
*/
3115
+
assumeUtf8?: boolean;
3111
3116
/**
3112
3117
* 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.
Copy file name to clipboardExpand all lines: lib/css/cssMinify.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@
35
35
* re-resolves in the worker — via the installed package, or the dev self-link.
36
36
* @param {{ [file: string]: string | Buffer }} input a single `{ filename: code }` entry; a `Buffer` is read as UTF-8
37
37
* @param {object=} sourceMap the asset's input source map — the plugin chains it onto the map returned here, so it isn't read directly
38
-
* @param {{ as?: "stylesheet" | "block-contents", environment?: CssEnvironment, convertLengthUnits?: boolean, convertApproximateColors?: boolean, dropOverriddenDeclarations?: boolean, extractComments?: MinimizeExtractComments, mergeDistantRules?: boolean, rewriteCustomProperties?: boolean, unusedSymbols?: string[], pseudoClasses?: { [name: string]: string }, renderEmbeddedSource?: AsyncEmbeddedSourceRenderer } & CssTransformOptions=} minimizerOptions minimizer options — `environment` carries the target's CSS abilities (see `output.environment`), so a spelling the target cannot read is not reached for; the rest is `optimization.minimize.css` (e.g. `convertLengthUnits`, and the per-transform switches). `renderEmbeddedSource` minifies source this stylesheet embeds, and may be asynchronous: one parse serves both it and the output. Its `extractComments` decides which comments move into a separate file, over the plugin's
38
+
* @param {{ as?: "stylesheet" | "block-contents", environment?: CssEnvironment, assumeUtf8?: boolean, convertLengthUnits?: boolean, convertApproximateColors?: boolean, dropOverriddenDeclarations?: boolean, extractComments?: MinimizeExtractComments, mergeDistantRules?: boolean, rewriteCustomProperties?: boolean, unusedSymbols?: string[], pseudoClasses?: { [name: string]: string }, renderEmbeddedSource?: AsyncEmbeddedSourceRenderer } & CssTransformOptions=} minimizerOptions minimizer options — `environment` carries the target's CSS abilities (see `output.environment`), so a spelling the target cannot read is not reached for; the rest is `optimization.minimize.css` (e.g. `convertLengthUnits`, and the per-transform switches). `renderEmbeddedSource` minifies source this stylesheet embeds, and may be asynchronous: one parse serves both it and the output. Its `extractComments` decides which comments move into a separate file, over the plugin's
39
39
* @param {ExtractCommentsOption=} extractComments the plugin's `extractComments`, read where `minimize.css.extractComments` is not set
40
40
* @returns {Promise<{ code: string, map?: SourceMap, extractedComments?: string[], warnings?: (Error | string)[], errors?: (Error | string)[] }>} the minified CSS, its input->output source map (one anchor for the whole of a `block-contents` print, which is emitted as one piece), the comments taken out of it, and what a renderer reported over what this embeds
41
41
*/
@@ -97,6 +97,7 @@ const cssMinify = async (
97
97
const{
98
98
as,
99
99
environment,
100
+
assumeUtf8,
100
101
convertLengthUnits,
101
102
convertApproximateColors,
102
103
dropOverriddenDeclarations,
@@ -118,6 +119,7 @@ const cssMinify = async (
118
119
// A file of its own reads `@charset`; the declarations of a `style=""` are
119
120
// read in the document's encoding, and have no opening bytes to hold one.
* @property {string=} content the input's contents for the map's `sourcesContent`; only read while printing
4412
4413
* @property {CssEnvironment=} environment what the target can read (the CSS entries of `output.environment`), so a spelling it would not understand is never reached for; only read while printing, and an absent entry means the modern spelling is available
4413
4414
* @property {boolean=} declareCharset open the stylesheet with `@charset "UTF-8"` exactly when its output holds a non-ASCII character, so it is read as UTF-8 wherever it is served, and write a string's hex escape of a character past U+FFFF as the character, which costs fewer bytes once compressed; for a stylesheet that is a file of its own, as `@charset` is read only as one's opening bytes. Off by default, and only read while printing
4415
+
* @property {boolean=} assumeUtf8 the stylesheet is read as UTF-8 wherever it is served, so no `@charset` is written for it and a string's hex escape of a character past U+FFFF is written as the character, as `declareCharset` writes it. Off by default, and only read while printing
4414
4416
* @property {boolean=} convertLengthUnits rewrite a length into a shorter unit it is exactly equal in (`16px` -> `1pc`); off by default because it earns nothing once the asset is compressed, and only read while printing. A time is always rewritten
4415
4417
* @property {boolean=} convertApproximateColors write a polar or Lab color as the nearest hex even where that hex only approximates it: a channel too near a `.5` boundary for two engines to round it alike, and a color outside the sRGB gamut, which hex can only clip. Off by default, and only read while printing; a space engines read through transfers of their own (`a98-rgb`, `prophoto-rgb`) is left alone either way
4416
4418
* @property {boolean=} mergeDistantRules give a rule the selectors of a later one printing the same block, and an at-rule the block of a later one stating the same condition, past the rules between them; off by default, since it reorders the cascade and is sound only where nothing between declares what the block being moved does for an element it can match — a condition between counting for what its own rules declare
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
@@ -4021,6 +4021,11 @@
4021
4021
"type": "object",
4022
4022
"additionalProperties": false,
4023
4023
"properties": {
4024
+
"assumeUtf8": {
4025
+
"description": "State that each `.css` asset is read as UTF-8 wherever it is served, so the minimizer writes no `@charset \"UTF-8\"` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's `content: \"\\F0A86\"`) as the character itself, as it does once that `@charset` is written. Off by default, because the statement must be true: a stylesheet with no `@charset` is read in the encoding the server's `Content-Type` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.",
4026
+
"type": "boolean",
4027
+
"added": "5.112.0"
4028
+
},
4024
4029
"colorFallbacks": {
4025
4030
"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.",
Copy file name to clipboardExpand all lines: test/__snapshots__/Cli.basictest.js.snap
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11261,6 +11261,19 @@ Object {
11261
11261
"multiple": false,
11262
11262
"simpleType": "boolean",
11263
11263
},
11264
+
"optimization-minimize-css-assume-utf8": Object {
11265
+
"configs": Array [
11266
+
Object {
11267
+
"description": "State that each \`.css\` asset is read as UTF-8 wherever it is served, so the minimizer writes no \`@charset \\"UTF-8\\"\` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's \`content: \\"\\\\F0A86\\"\`) as the character itself, as it does once that \`@charset\` is written. Off by default, because the statement must be true: a stylesheet with no \`@charset\` is read in the encoding the server's \`Content-Type\` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.",
11268
+
"multiple": false,
11269
+
"path": "optimization.minimize.css.assumeUtf8",
11270
+
"type": "boolean",
11271
+
},
11272
+
],
11273
+
"description": "State that each \`.css\` asset is read as UTF-8 wherever it is served, so the minimizer writes no \`@charset \\"UTF-8\\"\` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's \`content: \\"\\\\F0A86\\"\`) as the character itself, as it does once that \`@charset\` is written. Off by default, because the statement must be true: a stylesheet with no \`@charset\` is read in the encoding the server's \`Content-Type\` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.",
"description": "State that each \`.css\` asset is read as UTF-8 wherever it is served, so the minimizer writes no \`@charset \\"UTF-8\\"\` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's \`content: \\"\\\\F0A86\\"\`) as the character itself, as it does once that \`@charset\` is written. Off by default, because the statement must be true: a stylesheet with no \`@charset\` is read in the encoding the server's \`Content-Type\` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.",
"description": "State that each \`.css\` asset is read as UTF-8 wherever it is served, so the minimizer writes no \`@charset \\"UTF-8\\"\` before one holding a non-ASCII character, and writes an escaped character past U+FFFF (an icon font's \`content: \\"\\\\F0A86\\"\`) as the character itself, as it does once that \`@charset\` is written. Off by default, because the statement must be true: a stylesheet with no \`@charset\` is read in the encoding the server's \`Content-Type\` names, else in the encoding of the page linking it, so it holds wherever the server names UTF-8 or the page is UTF-8 — and anywhere else every such character reads as other characters.",
0 commit comments