@@ -35,7 +35,6 @@ interface BuildDependencies {
3535 cleanCssSanitizeOptions : unknown ;
3636 cleanCssDevOptions : unknown ;
3737 devextremeVersion : string ;
38- browsersList : string [ ] ;
3938}
4039
4140type MinifyProfile = 'all' | 'ci' ;
@@ -52,9 +51,13 @@ function resolveDataUri(filePath: string, svgEncoding?: string): string {
5251 return `data:image/${ ext } ;base64,${ data . toString ( 'base64' ) } ` ;
5352}
5453
55- function createLicenseHeader ( fileName : string , version : string ) : string {
54+ /**
55+ * Same shape as `packages/devextreme/build/gulp/license-header.txt` with
56+ * `gulp-header` `commentType: '*'` (starLicense) — matches legacy Gulp output.
57+ */
58+ function createStarLicenseHeader ( fileName : string , version : string ) : string {
5659 return [
57- '/*! ' ,
60+ '/** ' ,
5861 `* DevExtreme (${ fileName . replace ( / \\ / g, '/' ) } )` ,
5962 `* Version: ${ version } ` ,
6063 `* Build date: ${ new Date ( ) . toDateString ( ) } ` ,
@@ -66,16 +69,13 @@ function createLicenseHeader(fileName: string, version: string): string {
6669 ] . join ( '\n' ) ;
6770}
6871
69- function moveCharsetToTop ( css : string ) : string {
70- const match = css . match ( / @ c h a r s e t \s + [ ^ ; ] + ; \s * / ) ;
71- if ( ! match ) {
72- return css ;
73- }
74-
75- const charset = match [ 0 ] . trim ( ) ;
76- const withoutCharset = css . replace ( match [ 0 ] , '' ) . replace ( / ^ \s + / , '' ) ;
77-
78- return `${ charset } \n${ withoutCharset } ` ;
72+ /**
73+ * Mirrors `style-compiler.js`: starLicense prepend, then
74+ * `.replace(/([\s\S]*)(@charset.*?;\s)/, '$2$1')` so `@charset` is the first bytes of output.
75+ */
76+ function prependLicenseAndMoveCharsetFirst ( minifiedCss : string , license : string ) : string {
77+ const withLicense = `${ license } ${ minifiedCss } ` ;
78+ return withLicense . replace ( / ( [ \s \S ] * ) ( @ c h a r s e t [ ^ ; ] + ; \s * ) / , '$2$1' ) ;
7979}
8080
8181function generateBundleName ( theme : string , size : string , color : string , mode ?: string ) : string {
@@ -136,8 +136,6 @@ function loadDependencies(projectRoot: string): BuildDependencies {
136136 ) ,
137137 devextremeVersion : workspaceRequire ( path . resolve ( projectRoot , '../devextreme/package.json' ) )
138138 . version ,
139- browsersList : workspaceRequire ( path . resolve ( projectRoot , '../devextreme/package.json' ) )
140- . browserslist ,
141139 } ;
142140}
143141
@@ -199,12 +197,8 @@ async function compileFile(
199197 } ) ;
200198
201199 const postcssFactory = ( deps . postcss as unknown as { default ?: any } ) . default || deps . postcss ;
202- const prefixed = await postcssFactory ( [
203- deps . autoprefixer ( {
204- overrideBrowserslist : deps . browsersList ,
205- } ) ,
206- ] ) . process ( compiled . css , {
207- from : undefined ,
200+ const prefixed = await postcssFactory ( [ deps . autoprefixer ( ) ] ) . process ( compiled . css , {
201+ from : sourceFile ,
208202 } ) ;
209203
210204 const minifierOptions =
@@ -213,8 +207,8 @@ async function compileFile(
213207 const minified = minifier . minify ( prefixed . css ) . styles ;
214208
215209 const outFileName = path . basename ( sourceFile , '.scss' ) + '.css' ;
216- const withHeader =
217- createLicenseHeader ( outFileName , deps . devextremeVersion ) + moveCharsetToTop ( minified ) ;
210+ const license = createStarLicenseHeader ( outFileName , deps . devextremeVersion ) ;
211+ const withHeader = prependLicenseAndMoveCharsetFirst ( minified , license ) ;
218212 await writeFileText ( path . join ( outputDir , outFileName ) , withHeader ) ;
219213}
220214
0 commit comments