@@ -12,6 +12,10 @@ import * as child_process from "child_process";
1212import { patchCssForMui } from "./patchCssForMui" ;
1313import yargsParser from "yargs-parser" ;
1414
15+ function removeCharset ( rawCssCode : string ) : string {
16+ return rawCssCode . replace ( / @ c h a r s e t " U T F - 8 " ; \s * / g, "" ) ;
17+ }
18+
1519( async ( ) => {
1620 const argv = yargsParser ( process . argv . slice ( 2 ) ) ;
1721
@@ -31,22 +35,32 @@ import yargsParser from "yargs-parser";
3135 "recursive" : true
3236 } ) ;
3337
34- {
35- const filePath = pathJoin ( dsfrDirPath , "dsfr.css" ) ;
36-
37- const dsfrCssContent = fs . readFileSync ( filePath ) . toString ( "utf8" ) ;
38-
39- const dsfrCssContent_patched = dsfrCssContent . replace ( '@charset "UTF-8";' , "" ) ;
40-
41- fs . writeFileSync ( filePath , Buffer . from ( dsfrCssContent_patched , "utf8" ) ) ;
42- }
43-
4438 fs . cpSync (
4539 pathJoin ( __dirname , "marianne-index.css" ) ,
4640 pathJoin ( dsfrDirPath , "fonts" , "index.css" )
4741 ) ;
4842
49- const rawDsfrCssCode = fs . readFileSync ( pathJoin ( dsfrDirPath , "dsfr.css" ) ) . toString ( "utf8" ) ;
43+ {
44+ const iconsDirPath = pathJoin ( dsfrDirPath , "utility" , "icons" ) ;
45+
46+ (
47+ [
48+ [ "icons.main.css" , "icons.css" ] ,
49+ [ "icons.main.min.css" , "icons.min.css" ]
50+ ] as const
51+ ) . forEach ( ( [ sourceBasename , targetBasename ] ) =>
52+ fs . copyFileSync (
53+ pathJoin ( iconsDirPath , sourceBasename ) ,
54+ pathJoin ( iconsDirPath , targetBasename )
55+ )
56+ ) ;
57+ }
58+
59+ const rawDsfrCssCode = [ "dsfr.main.css" , "dsfr.print.css" ]
60+ . map ( fileBasename =>
61+ removeCharset ( fs . readFileSync ( pathJoin ( dsfrDirPath , fileBasename ) ) . toString ( "utf8" ) )
62+ )
63+ . join ( "\n" ) ;
5064
5165 fs . writeFileSync (
5266 pathJoin (
0 commit comments