import adapter from '@sveltejs/adapter-bun'; import devtoolsJson from 'vite-plugin-devtools-json'; import tailwindcss from '@tailwindcss/vite'; import { defineConfig, type Plugin } from 'vitest/config'; import type { Server } from 'node:http'; import { attachSockets } from './src/lib/server/ws-attach.ts'; import { sveltekit } from '@sveltejs/kit/vite'; import { sentrySvelteKit } from '@sentry/sveltekit'; function matchSocket(): Plugin { return { name: 'esports-match-socket', configureServer(server) { if (server.httpServer) void attachSockets(server.httpServer as Server); } }; } // Stub import-in-the-middle — its ESM loader hooks are Node-only and crash Bun. // Sentry's manual error tracking (sentryHandle, captureException) still works; // only automatic OpenTelemetry instrumentation is disabled. function stubIITM(): Plugin { return { name: 'stub-import-in-the-middle', resolveId(id) { if (id === 'import-in-the-middle' || id.startsWith('import-in-the-middle/')) { return '\0iitm-stub'; } }, load(id) { if (id === '\0iitm-stub') { return 'export class Hook { constructor() {} enable() {} disable() {} unhook() {} }'; } } }; } export default defineConfig({ plugins: [ stubIITM(), tailwindcss(), sentrySvelteKit({ org: 'vash-software-vr', project: 'esports', authToken: process.env.SENTRY_AUTH_TOKEN, telemetry: false }), sveltekit({ adapter: adapter(), csrf: { trustedOrigins: ['https://esports-dev.vash.software'] } }), devtoolsJson(), matchSocket() ], ssr: { external: ['bun'] }, build: { rollupOptions: { external: ['bun'] }, reportCompressedSize: false }, server: { host: '127.0.0.1', port: 3102, allowedHosts: ['esports-dev.vash.software'], ws: process.env.AUTH_E2E === '1' ? false : { host: 'esports-dev.vash.software', protocol: 'wss', clientPort: 443 } }, test: { expect: { requireAssertions: true }, environment: 'node', include: ['src/**/*.{test,spec}.{js,ts}'] } });