import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { VitePWA } from "vite-plugin-pwa"; const backend = process.env.CODECRAFT_BACKEND ?? "http://127.0.0.1:8787"; export default defineConfig({ plugins: [ react(), VitePWA({ registerType: "autoUpdate", includeAssets: ["icon.svg", "apple-touch-icon.png"], manifest: { name: "CodeCraft", short_name: "CodeCraft", description: "Web-based coding harness for AI models", theme_color: "#282828", background_color: "#282828", display: "standalone", start_url: "/", id: "/", scope: "/", orientation: "any", categories: ["developer", "productivity"], icons: [ { src: "icon-192.png", sizes: "192x192", type: "image/png" }, { src: "icon-512.png", sizes: "512x512", type: "image/png" }, { src: "icon-maskable-512.png", sizes: "512x512", type: "image/png", purpose: "maskable" }, { src: "icon.svg", sizes: "any", type: "image/svg+xml" }, ], screenshots: [ { src: "screenshots/wide.png", sizes: "1400x860", type: "image/png", form_factor: "wide", label: "Chat with an agent" }, { src: "screenshots/narrow.png", sizes: "780x1688", type: "image/png", form_factor: "narrow", label: "CodeCraft on the phone" }, ], }, workbox: { // The API is always live data; only the app shell is cached. navigateFallbackDenylist: [/^\/api/, /^\/cli/], runtimeCaching: [], // The STEP importer (OpenCascade, ~8 MB) is loaded only when needed. globIgnores: ["**/occt-import-js*"], // Web Push handlers (push, notificationclick). importScripts: ["push-sw.js"], }, }), ], server: { proxy: { "/api": { target: backend, ws: true, changeOrigin: true }, }, }, });