import react from '@vitejs/plugin-react'; import { defineConfig } from 'vitest/config'; // The config is kept minimal: in Vite 8 (Rolldown) some old options became a silent no-op, so // every line below is here deliberately and with a reason. export default defineConfig({ plugins: [react()], // A proxy rather than the platform's address in the code: the frontend must live on the SAME // origin. That is a fact and not a setting — the platform has no CORS layer at all, and a // preflight OPTIONS carrying a foreign Origin is answered 401 by the session guard (measured on // the live binary, acceptance №15). A cross-origin browser client is therefore inoperable as a // class, and in development the only working path is our own origin over a proxy. // Without TM_PLATFORM the proxy does not come up: by default the network is held by MSW. server: process.env.TM_PLATFORM ? { proxy: { '/v0': process.env.TM_PLATFORM, '/auth': process.env.TM_PLATFORM } } : undefined, // The same flag is visible to the client: without it the mock worker would intercept the request // BEFORE the proxy, and the setting would look broken rather than shadowed. define: { 'import.meta.env.VITE_TM_PLATFORM': JSON.stringify(process.env.TM_PLATFORM ?? ''), }, // Lightning CSS instead of esbuild for minification — the pin from STACK_DECISIONS §2. build: { cssMinify: 'lightningcss' }, test: { environment: 'happy-dom', // By default Vitest serves an empty stub instead of CSS — the token contract test would then // be checking emptiness and would always be green. css: true, include: ['src/**/*.test.{ts,tsx}'], }, });