mirror of
https://github.com/penpot/penpot.git
synced 2026-10-28 21:40:34 +00:00
🐛 Move the CSS @charset to the start of the bundled stylesheet
Sass adds @charset "UTF-8" to every module with non-ASCII characters, and concatSass joined the modules as they came, so main.css carried it in the middle of the file. Browsers only honor @charset as the first rule, and the server sends text/css with no charset. When the browser did not take the page encoding for the stylesheet, it read main.css as Latin-1 and CSS content such as the bullet of the library element counts showed as "•". Drop every @charset while joining the modules and put one at the start. Closes #12677 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
506923e2e9
commit
fc4adcdf4d
@ -165,9 +165,22 @@ export async function compileSassAll(worker) {
|
||||
|
||||
export function concatSass(data) {
|
||||
const output = [];
|
||||
const charset = '@charset "UTF-8";';
|
||||
let hasCharset = false;
|
||||
|
||||
// Sass adds @charset to each file with non-ASCII characters. Browsers
|
||||
// only honor it as the first rule of the stylesheet, so move it there.
|
||||
for (let path of data.items) {
|
||||
output.push(data.index[path]);
|
||||
let css = data.index[path];
|
||||
if (css.includes(charset)) {
|
||||
hasCharset = true;
|
||||
css = css.replaceAll(charset + "\n", "").replaceAll(charset, "");
|
||||
}
|
||||
output.push(css);
|
||||
}
|
||||
|
||||
if (hasCharset) {
|
||||
output.unshift(charset);
|
||||
}
|
||||
|
||||
return output.join("\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user