diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index 60c59e8f6d..9a6bf14ec8 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -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");