Files
HMDesign/scripts/finalize-dashboard-export.mjs

18 lines
560 B
JavaScript

import { readFile, writeFile } from "node:fs/promises"
const path = "dist-dashboard/index.html"
const html = await readFile(path, "utf8")
const finalized = html.replace(
'<script type="module" crossorigin src="./assets/dashboard-export.js"></script>',
'<script defer src="./assets/dashboard-export.js"></script>',
).replace(
/(<link\s+rel="stylesheet")\s+crossorigin(\s+href="\.\/assets\/[^\"]+\.css")/,
"$1$2",
)
if (finalized === html) {
throw new Error(`Dashboard export script tag was not found in ${path}`)
}
await writeFile(path, finalized)