* * @param {String} htmlFile
(htmlFile)
| 25 | * @param {String} htmlFile |
| 26 | */ |
| 27 | function loadStyles(htmlFile) { |
| 28 | let styles = "<!--styles-->"; |
| 29 | |
| 30 | for (let cssFile of cssFiles) { |
| 31 | styles += `\n<link rel="stylesheet" href="${CSS_PATH}${cssFile}">`; |
| 32 | } |
| 33 | |
| 34 | styles += "\n<!--styles_end-->\n"; |
| 35 | |
| 36 | const rgx = |
| 37 | /<!--styles-->([^<]*(?:<(?!!--styles_end-->)[^<]*)*)<!--styles_end-->\n*/gim; |
| 38 | let html = fs.readFileSync(htmlFile, "utf8"); |
| 39 | html = html.replace(rgx, ""); |
| 40 | html = html.replace("</head>", styles + "</head>"); |
| 41 | fs.writeFileSync(htmlFile, html); |
| 42 | } |