import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' // The backend port. Overridable because 8000 is a popular default and another // local app squatting it silently shadows this API (its SPA catch-all answers // GET /api/* with index.html), which looks like an empty database rather than // a proxy problem. Start the backend elsewhere and set AIDND_API_PORT to match. const apiPort = process.env.AIDND_API_PORT || '8000' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], server: { proxy: { '/api': `http://localhost:${apiPort}`, }, }, // M8's component tests. `jsdom` rather than a real browser on purpose: these // check deterministic rendering and wiring — which control is disabled, which // words appear, what a click calls — and the real browser suite covers what // only a real browser can. One is not a substitute for the other, and running // the fast one in a browser would make it slow enough to stop being run. // The React plugin's JSX transform does not reach files Vitest loads, so the // automatic runtime is named here as well. Without it every `.jsx` test fails // with "React is not defined" — the classic runtime's implicit global. esbuild: { jsx: 'automatic' }, test: { environment: 'jsdom', globals: true, setupFiles: './src/test/setup.js', include: ['src/**/*.test.{js,jsx}'], css: false, }, })