import tailwindcss from "@tailwindcss/vite"; import react from "@vitejs/plugin-react"; import { rm } from "node:fs/promises"; import { join } from "node:path"; import { defineConfig, type Plugin } from "vite"; /** * The user's source map art (public/assets/map) is large and only an input to * scripts/map-art.mjs; the app loads public/assets/map-gen. Drop the sources * from the build output (decision 0.5.37). */ function omitSourceArt(): Plugin { let outDir = "dist"; return { name: "omit-source-art", apply: "build", configResolved(config) { outDir = config.build.outDir; }, async closeBundle() { await rm(join(outDir, "assets/map"), { recursive: true, force: true }); }, }; } export default defineConfig({ plugins: [react(), tailwindcss(), omitSourceArt()], server: { // Same-domain API in development too (decision 0.5.20). The server listens on // IPv4 only, so target 127.0.0.1 rather than localhost. // API_PROXY_TARGET lets a second dev stack (e.g. screenshots) use another API port. proxy: { "/api": process.env.API_PROXY_TARGET ?? "http://127.0.0.1:3000" }, }, });