blob: 511ab7a3b5b80b764e914397805a04d260dc9d62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/**
* Injects the theme preload script into index.html.
* Run this as part of the build process.
*/
import { generatePreloadScript } from "@opencode-ai/ui/theme"
const htmlPath = new URL("../index.html", import.meta.url).pathname
const html = await Bun.file(htmlPath).text()
const script = generatePreloadScript()
const injectedHtml = html.replace(
/<script id="oc-theme-preload-script">\s*\/\* THEME_PRELOAD_SCRIPT \*\/\s*<\/script>/,
`<script id="oc-theme-preload-script">${script}</script>`,
)
await Bun.write(htmlPath, injectedHtml)
console.log("Injected theme preload script into index.html")
|