import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; export default defineConfig({ // CRA's Babel loader accepted JSX inside .js files. Production sources have // been renamed to .jsx, but the a4 test files are still .js containing JSX, // so the transform is widened to parse .js as JSX too. This works on the // dev/test path; the bundled build path derives the language from the file // extension, which is why the production file had to be renamed. plugins: [react({ include: /\.(js|jsx)$/ })], oxc: { include: /\.(m?ts|[jt]sx|js)$/, exclude: /node_modules/, lang: 'jsx', }, server: { // Must stay 5172 — Django's CORS_ALLOWED_ORIGINS allowlists this origin. port: 5172, strictPort: true, // Replicates CRA's "proxy": "http://localhost:8002". The app calls the API // with absolute URLs (VITE_API_URL), so this only matters as a fallback // for a relative /api request. proxy: { '/api': 'http://localhost:8002', }, }, build: { // Kept as CRA's 'build' rather than Vite's default 'dist' so the existing // Dockerfile (COPY --from=builder /app/build) keeps working. outDir: 'build', }, test: { environment: 'jsdom', globals: true, include: ['src/**/*.test.{js,jsx}'], }, });