import { wayfinder } from '@laravel/vite-plugin-wayfinder'; import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; import laravel from 'laravel-vite-plugin'; import { defineConfig } from 'vite'; const devServerHost = process.env.VITE_DEV_SERVER_HOST ?? '0.0.0.0'; const devServerPort = Number.parseInt(process.env.VITE_DEV_SERVER_PORT ?? '5173', 10); const devServerOrigin = process.env.VITE_DEV_SERVER_URL ?? `http://localhost:${devServerPort}`; const parsedOrigin = new URL(devServerOrigin); const hmrPort = parsedOrigin.port === '' ? devServerPort : Number.parseInt(parsedOrigin.port, 10); const appUrl = process.env.APP_URL ?? 'http://localhost:8000'; export default defineConfig({ server: { host: devServerHost, port: devServerPort, strictPort: true, origin: devServerOrigin, hmr: { host: parsedOrigin.hostname, protocol: parsedOrigin.protocol.replace(':', ''), port: hmrPort, }, cors: { origin: appUrl, credentials: true, }, }, plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.tsx', 'resources/js/guest/main.tsx', 'resources/js/admin/main.tsx'], ssr: 'resources/js/ssr.tsx', refresh: true, }), react(), tailwindcss(), wayfinder({ formVariants: true, }), ], esbuild: { jsx: 'automatic', }, });