import { fileURLToPath, URL } from 'node:url'; import react from '@vitejs/plugin-react'; import { configDefaults, defineConfig } from 'vitest/config'; import { trackedSourceFilesPlugin } from './vite-plugins/trackedSourceFiles'; const aspNetHost = 'http://localhost:8409'; export default defineConfig({ base: '/app/', plugins: [react(), trackedSourceFilesPlugin()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), '@design-system': fileURLToPath(new URL('../design-system', import.meta.url)) } }, build: { outDir: '../ErsatzTV/wwwroot/app', emptyOutDir: true }, server: { port: 5173, strictPort: false, proxy: { '/api': aspNetHost, '/iptv': aspNetHost, '/artwork': aspNetHost } }, test: { environment: 'jsdom', environmentOptions: { jsdom: { url: 'http://localhost/app/' } }, // `e2e/` holds the Playwright UI-E2E specs (ersatztv#445), which drive a REAL browser against a // running instance. Vitest's default `include` glob (`**/*.{test,spec}.*`) would otherwise pick // them up and run them under jsdom, where `@playwright/test`'s `test()` has no runner and the // whole file dies. Spread the defaults rather than replacing `exclude` outright — a bare // `exclude: ['e2e/**']` would drop `**/node_modules/**` and make vitest crawl deps. // NOTE: excluding (not narrowing `include` to `src/**`) is deliberate — `scripts/` holds a real // vitest test too (`generate-openapi-types.test.mjs`), which an `src/**`-only include would // silently stop running. exclude: [...configDefaults.exclude, 'e2e/**'], setupFiles: './src/setupTests.ts' } });