space-game/vite.config.ts
Michael Mainguy ee90e420d6
All checks were successful
Build / build (push) Successful in 1m21s
Fix mesh rendering and CloudFlare proxy compatibility
## Major Fixes

### 1. Fixed Invisible Meshes Issue
- Root cause: Emissive materials require disableLighting=true without scene lighting
- Added disableLighting=true to all loaded materials in loadAsset.ts
- Scene intentionally uses no dynamic lights (space game with emissive textures)

### 2. Fixed CloudFlare Proxy + Vite Cache Issues
- Updated vite.config.ts to pre-bundle BabylonJS procedural textures
- Added force:false to prevent unnecessary cache invalidation
- Fixed 504 Gateway Timeout errors on shader module dynamic imports
- Separated babylon-procedural chunk for better caching

### 3. Responsive Design Improvements
- Consolidated all CSS into public/styles.css with design tokens
- Removed duplicate styles.css file
- Created semantic header with navigation
- Extracted 300+ lines of inline styles to CSS classes
- Added mobile-first responsive breakpoints (320px, 480px, 768px, 1024px, 1440px)
- Implemented fluid typography with clamp()

### 4. Level Progression System
- Fixed level unlocking logic (tutorial always unlocked, others require auth)
- Updated DEFAULT_LEVEL_ORDER to match actual level names
- Made populateLevelSelector() async to properly await authentication
- Added 3-column carousel layout for level selection
- Visual states: locked, unlocked, current, completed

### 5. Discord Widget Management
- Disabled Discord widget initialization (commented out) to prevent GraphQL errors
- Added hide() call during gameplay
- Can be re-enabled when Discord bot is properly configured

### 6. TypeScript Error Fixes
- Removed unused hasSavedLevels import
- Updated replay callbacks to use appHeader instead of individual link references
- Fixed all TS compilation errors

## Files Modified
- index.html - Semantic header, removed inline styles
- public/styles.css - Consolidated styles with design tokens
- src/gameConfig.ts - Enabled progression by default
- src/levelSelector.ts - Fixed progression logic, async auth check
- src/loginScreen.ts - Removed inline styles
- src/main.ts - Discord handling, header visibility, error suppression
- src/preloader.ts - Removed inline styles
- src/progression.ts - Added isLevelUnlocked() method
- src/utils/loadAsset.ts - Fixed emissive materials (disableLighting=true)
- vite.config.ts - Pre-bundle procedural textures, prevent cache issues
- styles.css - DELETED (consolidated into public/styles.css)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 06:13:48 -06:00

47 lines
1.2 KiB
TypeScript

import {defineConfig} from "vite";
/** @type {import('vite').UserConfig} */
export default defineConfig({
test: {},
define: {},
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'babylon': ['@babylonjs/core'],
'babylon-procedural': ['@babylonjs/procedural-textures']
}
}
}
},
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
},
preview: {
port: 3000,
},
base: "/"
})