summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-09 11:57:27 -0600
committeradamelmore <[email protected]>2026-01-09 11:57:31 -0600
commit0f2124db32606020766d237ce774a3c2e7783ee3 (patch)
tree9ebe345ecdb5cf4be8f8dcc88fac042c4980f1a3
parente30a159264713b045faf784f4799d2626ac9b78c (diff)
downloadopencode-0f2124db32606020766d237ce774a3c2e7783ee3.tar.gz
opencode-0f2124db32606020766d237ce774a3c2e7783ee3.zip
fix(app): no inline js
-rw-r--r--packages/app/index.html31
-rw-r--r--packages/app/public/oc-theme-preload.js28
-rw-r--r--packages/desktop/index.html31
-rw-r--r--packages/desktop/vite.config.ts1
4 files changed, 31 insertions, 60 deletions
diff --git a/packages/app/index.html b/packages/app/index.html
index 44fa3b989..e0fbe6913 100644
--- a/packages/app/index.html
+++ b/packages/app/index.html
@@ -14,36 +14,7 @@
<meta property="og:image" content="/social-share.png" />
<meta property="twitter:image" content="/social-share.png" />
<!-- Theme preload script - applies cached theme to avoid FOUC -->
- <script id="oc-theme-preload-script">
- ;(function () {
- var themeId = localStorage.getItem("opencode-theme-id")
- if (!themeId) return
-
- var scheme = localStorage.getItem("opencode-color-scheme") || "system"
- var isDark = scheme === "dark" || (scheme === "system" && matchMedia("(prefers-color-scheme: dark)").matches)
- var mode = isDark ? "dark" : "light"
-
- document.documentElement.dataset.theme = themeId
- document.documentElement.dataset.colorScheme = mode
-
- if (themeId === "oc-1") return
-
- var css = localStorage.getItem("opencode-theme-css-" + themeId + "-" + mode)
- if (css) {
- var style = document.createElement("style")
- style.id = "oc-theme-preload"
- style.textContent =
- ":root{color-scheme:" +
- mode +
- ";--text-mix-blend-mode:" +
- (isDark ? "plus-lighter" : "multiply") +
- ";" +
- css +
- "}"
- document.head.appendChild(style)
- }
- })()
- </script>
+ <script id="oc-theme-preload-script" src="/oc-theme-preload.js"></script>
</head>
<body class="antialiased overscroll-none text-12-regular overflow-hidden">
<noscript>You need to enable JavaScript to run this app.</noscript>
diff --git a/packages/app/public/oc-theme-preload.js b/packages/app/public/oc-theme-preload.js
new file mode 100644
index 000000000..f8c710496
--- /dev/null
+++ b/packages/app/public/oc-theme-preload.js
@@ -0,0 +1,28 @@
+;(function () {
+ var themeId = localStorage.getItem("opencode-theme-id")
+ if (!themeId) return
+
+ var scheme = localStorage.getItem("opencode-color-scheme") || "system"
+ var isDark = scheme === "dark" || (scheme === "system" && matchMedia("(prefers-color-scheme: dark)").matches)
+ var mode = isDark ? "dark" : "light"
+
+ document.documentElement.dataset.theme = themeId
+ document.documentElement.dataset.colorScheme = mode
+
+ if (themeId === "oc-1") return
+
+ var css = localStorage.getItem("opencode-theme-css-" + themeId + "-" + mode)
+ if (css) {
+ var style = document.createElement("style")
+ style.id = "oc-theme-preload"
+ style.textContent =
+ ":root{color-scheme:" +
+ mode +
+ ";--text-mix-blend-mode:" +
+ (isDark ? "plus-lighter" : "multiply") +
+ ";" +
+ css +
+ "}"
+ document.head.appendChild(style)
+ }
+})()
diff --git a/packages/desktop/index.html b/packages/desktop/index.html
index f93e97294..11e9f39a6 100644
--- a/packages/desktop/index.html
+++ b/packages/desktop/index.html
@@ -13,36 +13,7 @@
<meta name="theme-color" content="#131010" media="(prefers-color-scheme: dark)" />
<meta property="og:image" content="/social-share.png" />
<meta property="twitter:image" content="/social-share.png" />
- <script id="oc-theme-preload-script">
- ;(function () {
- var themeId = localStorage.getItem("opencode-theme-id")
- if (!themeId) return
-
- var scheme = localStorage.getItem("opencode-color-scheme") || "system"
- var isDark = scheme === "dark" || (scheme === "system" && matchMedia("(prefers-color-scheme: dark)").matches)
- var mode = isDark ? "dark" : "light"
-
- document.documentElement.dataset.theme = themeId
- document.documentElement.dataset.colorScheme = mode
-
- if (themeId === "oc-1") return
-
- var css = localStorage.getItem("opencode-theme-css-" + themeId + "-" + mode)
- if (css) {
- var style = document.createElement("style")
- style.id = "oc-theme-preload"
- style.textContent =
- ":root{color-scheme:" +
- mode +
- ";--text-mix-blend-mode:" +
- (isDark ? "plus-lighter" : "multiply") +
- ";" +
- css +
- "}"
- document.head.appendChild(style)
- }
- })()
- </script>
+ <script id="oc-theme-preload-script" src="/oc-theme-preload.js"></script>
</head>
<body class="antialiased overscroll-none text-12-regular overflow-hidden">
<noscript>You need to enable JavaScript to run this app.</noscript>
diff --git a/packages/desktop/vite.config.ts b/packages/desktop/vite.config.ts
index 37bc63393..62c3a099a 100644
--- a/packages/desktop/vite.config.ts
+++ b/packages/desktop/vite.config.ts
@@ -6,6 +6,7 @@ const host = process.env.TAURI_DEV_HOST
// https://vite.dev/config/
export default defineConfig({
plugins: [appPlugin],
+ publicDir: "../app/public",
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors