import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; const productionCsp = "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; connect-src 'self' ipc: http://ipc.localhost"; const developmentCsp = "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' http://localhost:5173 ws://localhost:5173; connect-src 'self' ipc: http://ipc.localhost http://localhost:5173 ws://localhost:5173 http://127.0.0.1:4173"; export default defineConfig(({ command }) => ({ cacheDir: 'node_modules/.vite-client', plugins: [ react(), { name: 'assessor-csp', transformIndexHtml(html) { return html.replace('__ASSESSOR_CSP__', command === 'serve' ? developmentCsp : productionCsp); } }, { name: 'assessor-dist-server-watch-guard', configureServer(server) { server.watcher.on('error', (error: NodeJS.ErrnoException) => { if (error.code === 'EINVAL' && error.message.includes('dist-server')) return; console.error('[assessor] Vite watcher error:', error); }); } } ], clearScreen: false, build: { outDir: 'dist', emptyOutDir: true }, server: { port: 5173, strictPort: true, watch: { ignored: ['**/dist/**', '**/dist-server/**'] }, proxy: { '/api': { target: 'http://127.0.0.1:4173' } } } }));