import { execSync } from "node:child_process"; import path from "node:path"; import { cloudflare } from "@cloudflare/vite-plugin"; import tailwindcss from "@tailwindcss/vite"; import react from "@vitejs/plugin-react"; import { defineConfig, loadEnv } from "vite"; const gitSha = execSync("git rev-parse --short HEAD").toString().trim(); export default defineConfig(({ mode }) => { const env = loadEnv(mode, path.resolve(__dirname, "../.."), ""); const hasPostgres = !!(process.env.DATABASE_URL || env.DATABASE_URL); return { plugins: [react(), tailwindcss(), !hasPostgres && cloudflare()].filter(Boolean), server: { port: 6265, proxy: { "/api": { target: "http://127.0.0.1:8787", changeOrigin: true, ws: true, }, }, // Cloud smoke runs expose the dev server through a cloudflared quick // tunnel so sandbox-hosted agents can call the AK API. A named tunnel // (e.g. bodev.vtit-agent-coding.dev) gives a stable dev origin. allowedHosts: [".trycloudflare.com", ".vtit-agent-coding.dev"], }, build: { outDir: "dist/client", }, define: { __APP_VERSION__: JSON.stringify(gitSha), }, resolve: { dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"], alias: { "@": path.resolve(__dirname, "./src"), "@vtit-agent-coding/shared": path.resolve(__dirname, "../../packages/shared/src"), }, }, }; });