space-game/vite.config.ts
Michael Mainguy 28c1b2b2aa Fix routing, cleanup, and game restart issues
- Switch from svelte-spa-router to svelte-routing for clean URLs without hashes
- Fix relative asset paths to absolute paths (prevents 404s on nested routes)
- Fix physics engine disposal using scene.disablePhysicsEngine()
- Fix Ship observer cleanup to prevent stale callbacks after level disposal
- Add _gameplayStarted flag to prevent false game-end triggers during init
- Add hasAsteroidsToDestroy check to prevent false victory on restart
- Add RockFactory.reset() to properly reinitialize asteroid mesh between games
- Add null safety checks throughout RockFactory for static properties

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 11:21:05 -06:00

50 lines
1.4 KiB
TypeScript

import {defineConfig} from "vite";
import { svelte } from '@sveltejs/vite-plugin-svelte';
/** @type {import('vite').UserConfig} */
export default defineConfig({
plugins: [svelte()],
test: {},
define: {},
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'babylon': ['@babylonjs/core'],
'babylon-procedural': ['@babylonjs/procedural-textures'],
'babylon-inspector': ['@babylonjs/inspector'],
}
}
}
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'window',
}
},
// Include BabylonJS modules - force pre-bundle to prevent dynamic import issues
include: [
'@babylonjs/core',
'@babylonjs/loaders',
'@babylonjs/havok',
'@babylonjs/procedural-textures',
'@babylonjs/procedural-textures/fireProceduralTexture'
],
// Prevent cache invalidation issues with CloudFlare proxy
force: false,
// Exclude patterns that trigger unnecessary re-optimization
exclude: []
},
server: {
port: 3000,
allowedHosts: true
},
// appType: 'spa' is default - Vite automatically serves index.html for SPA routes
preview: {
port: 3000,
},
base: "/"
})