From 4b4227c049829df06a50553e0f875d35603661a5 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Wed, 25 Mar 2026 09:35:17 +0100 Subject: [PATCH 1/3] feat: embed main CSS inline instead of preloading Replaces the hint with a ` + const linkTag = `` function walk(dir) { for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { @@ -33,8 +35,9 @@ module.exports = function preloadCssPlugin() { function inject(filePath) { let html = fs.readFileSync(filePath, "utf8") - if (html.includes(preloadTag)) return - html = html.replace("
", `${preloadTag}`) + if (html.includes(styleTag)) return + html = html.replace(linkTag, "") + html = html.replace("", `${styleTag}`) fs.writeFileSync(filePath, html) } From bcec5470f3055baa94e2f3d1a2c3a3359f359c47 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Wed, 25 Mar 2026 09:57:52 +0100 Subject: [PATCH 2/3] fix: use cheerio DOM parsing to reliably remove stylesheet link String matching on the tag was fragile due to attribute order. Switch to cheerio so we select by attribute values regardless of order, and replaceWith() drops the external link and inlines the ` - const linkTag = `` function walk(dir) { for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { @@ -34,11 +31,14 @@ module.exports = function embedCssPlugin() { } function inject(filePath) { - let html = fs.readFileSync(filePath, "utf8") - if (html.includes(styleTag)) return - html = html.replace(linkTag, "") - html = html.replace("", `${styleTag}`) - fs.writeFileSync(filePath, html) + const html = fs.readFileSync(filePath, "utf8") + const $ = cheerio.load(html, { decodeEntities: false }) + + const link = $(`link[rel="stylesheet"][href$="${cssFile}"]`) + if (!link.length) return + + link.replaceWith(``) + fs.writeFileSync(filePath, $.html()) } walk(outDir) From c959a79d9756c9f9258363971bf3cc3ee0b6986a Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Wed, 25 Mar 2026 10:10:00 +0100 Subject: [PATCH 3/3] fix: replace cheerio with regex for CSS link removal Avoids a DOM parsing dependency for a simple string replacement. The regex matches the href regardless of attribute order. Co-Authored-By: Claude Sonnet 4.6