diff options
| author | Adam <[email protected]> | 2025-12-28 05:12:32 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-28 05:12:36 -0600 |
| commit | 4a9ff9412e8daedc36319bd2ee8ca62d5aa52be7 (patch) | |
| tree | ad035366cdebc87d4eea75475201af3d11bd64ed /packages/app/vite.js | |
| parent | d6db6ff198c4513ca5511ae49b03d4277bc21718 (diff) | |
| download | opencode-4a9ff9412e8daedc36319bd2ee8ca62d5aa52be7.tar.gz opencode-4a9ff9412e8daedc36319bd2ee8ca62d5aa52be7.zip | |
feat(desktop): themes
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(), ] |
