Skip to content

Commit 932d60b

Browse files
fix executor
1 parent 8c483b4 commit 932d60b

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/devextreme-themebuilder/src/modules/post-compiler.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function addBasePath(css: string | Buffer, basePath: string): string {
1313
export function addInfoHeader(
1414
css: string | Buffer,
1515
version: string,
16-
placeHeaderBeforeCharset = false,
16+
preserveCharsetBoundary = false,
1717
): string {
1818
const generatedBy = '* Generated by the DevExpress ThemeBuilder';
1919
const versionString = `* Version: ${version}`;
@@ -24,14 +24,16 @@ export function addInfoHeader(
2424
const encoding = '@charset "UTF-8";';
2525

2626
// clean-css may emit @charset immediately followed by :root / @import with no newline.
27-
// Keep backward-compatible output by default (charset + header), and allow parity mode
28-
// for compile pipeline where header should be before @charset.
27+
// Keep backward-compatible output by default (charset + header). In parity mode keep
28+
// @charset as the very first statement and move the info header to the end, so:
29+
// 1) charset decoding stays correct in browsers
30+
// 2) normalized comparison keeps '\n' between @charset and next rule.
2931
const charsetPrefix = /^@charset\s+"utf-8";\s*/i;
3032
const match = source.match(charsetPrefix);
3133
if (match) {
3234
const rest = source.slice(match[0].length).replace(/^\s*/, '');
33-
return placeHeaderBeforeCharset
34-
? `${header}${encoding}\n${rest}`
35+
return preserveCharsetBoundary
36+
? `${encoding}\n${rest}\n${header}`
3537
: `${encoding}\n${header}${rest}`;
3638
}
3739
return `${header}${source}`;

0 commit comments

Comments
 (0)