import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import path from 'path' export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { alias: { '@': path.resolve(__dirname, './src'), }, }, server: { port: 3000, host: true, // CRITICAL for the e2b shared pool: forbid Vite's default behaviour of // auto-picking another port on EADDRINUSE. The pool maps each port to a // specific projectSlug; if Vite for project A silently lands on the slot // belonging to project B, /webild-ready.json on the e2b host responds // with B's project id and the frontend sanity check fails (slugMismatch), // or worse, the iframe loads B's preview instead of A's. Better to crash // loudly so the outer while-loop + stop-sentinel can clean up. strictPort: true, // E2B exposes each port on `-.sandbox.webild.io`. Vite 8's // leading-dot wildcard (`.sandbox.webild.io`) refuses some patterns like // `-.sandbox.webild.io` with 403. These are dev-only // sandboxes — host check has no security value, so disable it entirely. allowedHosts: true, hmr: { // Browser connects via the same e2b-proxied https host on port 443, // but the dev server itself listens on raw `port`. Without this Vite // tells the client to open `wss://localhost:3000` and HMR fails. clientPort: 443, protocol: 'wss', }, }, })