/// import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [react()], // Keep Vitest's dependency cache separate from the browser test server. cacheDir: process.env.VITE_E2E === '1' ? 'node_modules/.vite-e2e' : undefined, optimizeDeps: process.env.VITE_E2E === '1' ? { // Lazy routes and workers must be scanned before browsers cache React chunks. // Late discovery otherwise mixes cached and newly optimized React instances // across full document navigations when HMR is disabled. entries: ['index.html', 'src/**/*.{ts,tsx}', '!src/**/*.test.{ts,tsx}', '!src/**/*.d.ts', '!src/test/**'], include: ['react', 'react-dom', 'react-dom/client', 'react/jsx-runtime', 'react/jsx-dev-runtime'], } : undefined, build: { target: 'es2022', }, server: { // E2E installs a stateful fake API in the page. A dev-server reload would // discard it in the middle of a scenario (including other parallel workers). hmr: process.env.VITE_E2E === '1' ? false : undefined, host: '127.0.0.1', port: 5173, strictPort: true, // В разработке API поднимается docker compose (deploy/compose.dev.yaml) на :8080 proxy: { '/api': 'http://localhost:8080', '/healthz': 'http://localhost:8080', }, }, test: { environment: 'jsdom', setupFiles: ['src/test/setup.ts'], exclude: ['e2e/**', 'node_modules/**'], }, });