diff --git a/package.json b/package.json index 6f0579f5f..ec72f42d2 100644 --- a/package.json +++ b/package.json @@ -257,7 +257,7 @@ "scripts": { "clean": "rm -rf dist", "build": "yarn clean && concurrently 'yarn build-translations' 'vite build' 'tsc --project tsconfig.lib.json' 'yarn build-styling'", - "build-styling": "sass src/styling/index.scss:dist/css/index.css src/styling/_emoji-replacement.scss:dist/css/emoji-replacement.css src/plugins/Emojis/styling/index.scss:dist/css/emoji-picker.css src/plugins/ChannelDetail/styling/index.scss:dist/css/channel-detail.css src/plugins/AIComponents/styling/index.scss:dist/css/ai-components.css; cp -r src/styling/assets dist/css/assets", + "build-styling": "sass --no-charset src/styling/index.scss:dist/css/index.css src/styling/_emoji-replacement.scss:dist/css/emoji-replacement.css src/plugins/Emojis/styling/index.scss:dist/css/emoji-picker.css src/plugins/ChannelDetail/styling/index.scss:dist/css/channel-detail.css src/plugins/AIComponents/styling/index.scss:dist/css/ai-components.css; cp -r src/styling/assets dist/css/assets", "build-translations": "node scripts/generate-i18n-keys.mts && prettier --write --log-level warn src/i18n/keys.ts", "coverage": "vitest run --coverage", "i18n:export": "node scripts/generate-i18n-keys.mts --json en.json", diff --git a/scripts/watch-styling.mjs b/scripts/watch-styling.mjs index 20bd6d815..d58daa012 100644 --- a/scripts/watch-styling.mjs +++ b/scripts/watch-styling.mjs @@ -108,6 +108,8 @@ const flushQueuedBuild = () => { const buildStyleEntry = async ({ entryFile, outputFile }) => { const { css, sourceMap } = await compileAsync(entryFile, { + // Same as `--no-charset` in `build-styling`: `@charset` is invalid once imported into a layer. + charset: false, sourceMap: true, style: 'expanded', }); diff --git a/src/plugins/AIComponents/styling/_ai-ui-icons.scss b/src/plugins/AIComponents/styling/_ai-ui-icons.scss index 08665e101..54a360ca3 100644 --- a/src/plugins/AIComponents/styling/_ai-ui-icons.scss +++ b/src/plugins/AIComponents/styling/_ai-ui-icons.scss @@ -1,3 +1,4 @@ +@use 'sass:string'; @use './tokens' as *; // The marks a reply's generated UI draws, the same in A2UI and OpenUI: glyphs and shapes in CSS, @@ -21,7 +22,9 @@ content: $glyph; } +// Non-ASCII glyphs stay CSS escapes in the output: Sass would otherwise write the characters +// themselves, so the stylesheet would decode right only as UTF-8 (it carries no `@charset`). $ai-ui-glyph-info: 'i'; -$ai-ui-glyph-success: '\2713'; +$ai-ui-glyph-success: string.unquote('"\\2713"'); $ai-ui-glyph-warning: '!'; -$ai-ui-glyph-danger: '\00d7'; +$ai-ui-glyph-danger: string.unquote('"\\00d7"');