diff options
Diffstat (limited to 'packages/app/vite.js')
| -rw-r--r-- | packages/app/vite.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/app/vite.js b/packages/app/vite.js index 6b8fd6137..5ab368836 100644 --- a/packages/app/vite.js +++ b/packages/app/vite.js @@ -1,6 +1,23 @@ import solidPlugin from "vite-plugin-solid" import tailwindcss from "@tailwindcss/vite" import { fileURLToPath } from "url" +import { generatePreloadScript } from "@opencode-ai/ui/theme" + +/** + * Vite plugin that injects the theme preload script into index.html. + * This ensures the theme is applied before the page renders, avoiding FOUC. + * @type {import("vite").Plugin} + */ +const themePreloadPlugin = { + name: "opencode-desktop:theme-preload", + transformIndexHtml(html) { + const script = generatePreloadScript() + return html.replace( + /<script id="oc-theme-preload-script">\s*\/\* THEME_PRELOAD_SCRIPT \*\/\s*<\/script>/, + `<script id="oc-theme-preload-script">${script}</script>`, + ) + }, +} /** * @type {import("vite").PluginOption} @@ -21,6 +38,7 @@ export default [ } }, }, + themePreloadPlugin, tailwindcss(), solidPlugin(), ] |
