// Vite config for the plugin SPA. `base: "./"` because the console serves the built // bundle from /plugin-ui// — asset URLs must stay relative to survive the proxy. // Dev has two modes (see src/mocks/): plain `bun run dev` runs entirely on fixtures, // `bun run dev:live` proxies /api to the plugin's dev server (plugin/src/dev.ts, :5885). import { fileURLToPath } from "node:url"; import tailwindcss from "@tailwindcss/vite"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; export default defineConfig({ base: "./", plugins: [react(), tailwindcss()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) }, }, // Scan only the app entry — without this the dev dep-scanner also crawls any // storybook-static/ build output sitting in the workspace and errors out. optimizeDeps: { entries: ["index.html"] }, build: { outDir: "../plugin/dist/ui", emptyOutDir: true, }, server: { port: 5599, ...(process.env.VITE_API_MODE === "live" ? { proxy: { "/api": { target: process.env.ROM_MANAGER_URL ?? "http://127.0.0.1:5885", }, }, } : {}), }, });