diff --git a/packages/app/vite.js b/packages/app/vite.js index f65a68a1cb..e1f851653c 100644 --- a/packages/app/vite.js +++ b/packages/app/vite.js @@ -5,6 +5,13 @@ import { fileURLToPath } from "url" const theme = fileURLToPath(new URL("./public/oc-theme-preload.js", import.meta.url)) +const channel = (() => { + const raw = process.env.OPENCODE_CHANNEL + if (raw === "dev" || raw === "beta" || raw === "prod") return raw + if (process.env.OPENCODE_CHANNEL === "latest") return "prod" + return "dev" +})() + /** * @type {import("vite").PluginOption} */ @@ -18,6 +25,9 @@ export default [ "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, + define: { + "import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel), + }, worker: { format: "es", }, diff --git a/packages/desktop/electron.vite.config.ts b/packages/desktop/electron.vite.config.ts index 52aa699ff6..6554aca346 100644 --- a/packages/desktop/electron.vite.config.ts +++ b/packages/desktop/electron.vite.config.ts @@ -3,14 +3,15 @@ import { defineConfig } from "electron-vite" import appPlugin from "@opencode-ai/app/vite" import * as fs from "node:fs/promises" +const OPENCODE_SERVER_DIST = "../opencode/dist/node" + const channel = (() => { const raw = process.env.OPENCODE_CHANNEL if (raw === "dev" || raw === "beta" || raw === "prod") return raw + if (process.env.OPENCODE_CHANNEL === "latest") return "prod" return "dev" })() -const OPENCODE_SERVER_DIST = "../opencode/dist/node" - const nodePtyPkg = `@lydell/node-pty-${process.platform}-${process.arch}` const sentry = @@ -82,9 +83,6 @@ export default defineConfig({ plugins: [appPlugin, sentry], publicDir: "../../../app/public", root: "src/renderer", - define: { - "import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel), - }, build: { sourcemap: true, rollupOptions: { diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index fa17d5762f..33db38d84c 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -58,7 +58,7 @@ const createEmbeddedWebUIBundle = async () => { console.log(`Building Web UI to embed in the binary`) const appDir = path.join(import.meta.dirname, "../../app") const dist = path.join(appDir, "dist") - await $`bun run --cwd ${appDir} build` + await $`OPENCODE_CHANNEL=${Script.channel} bun run --cwd ${appDir} build` const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist }))) .map((file) => file.replaceAll("\\", "/")) .filter((file) => !file.endsWith(".map"))