Open-source web player for Rublox games, dual-licensed under AGPL-3.0 + Commercial. Highlights: - Babylon.js 7 + React 18 + Vite 5 stack - Self-contained engine (~46k lines): BlockManager, ModelManager, PlayerController, ScriptSandboxWorker, MultiplayerSync, 30+ GD gamemodes - Configurable backend via VITE_API_BASE and friends — works against staging (dev-api.rublox.pro) out of the box - Standalone mode (VITE_STANDALONE=true) loads a bundled sample game for first-run without any backend - Full docs: README, ARCHITECTURE, CONTRIBUTING, SECURITY, CHANGELOG - Lint + format scaffolding (ESLint + Prettier + EditorConfig) - Legal: LICENSE (AGPL-3.0), LICENSE-COMMERCIAL.md, CLA.md, COPYRIGHT.md - Issue templates: bug_report, feature_request, security_disclosure Removed before public release: - frontend_deploy.py (contained production SSH credentials) - ~27 admin endpoints (kept in private repo) - Hard-coded internal URLs and IPs - All previous git history (clean repo init)
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
// Vite config for Rublox Player.
|
|
//
|
|
// - port 5173 is fixed (player code and external links assume it)
|
|
// - outDir 'build' (deployed under nginx /var/www/rublox-player/build/)
|
|
// - manualChunks split babylon/colyseus into separate chunks
|
|
// (engine ~46k lines, single-bundle build is >5 MB; browsers parse longer)
|
|
// - define for process.env.NODE_ENV — shim for engine code that used the
|
|
// CRA-provided global
|
|
// - dev proxy targets staging by default; override via VITE_API_PROXY_TARGET
|
|
// in .env.development.local to point at your own backend.
|
|
export default defineConfig(({ mode }) => {
|
|
// Load env so we can use VITE_API_PROXY_TARGET in proxy config.
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
const PROXY_TARGET = env.VITE_API_PROXY_TARGET || 'https://dev-api.rublox.pro';
|
|
|
|
// All backend prefixes the player talks to.
|
|
// Each entry creates a Vite proxy: /api-X/* → ${PROXY_TARGET}/api-X/*
|
|
const proxyPrefixes = ['/api-user', '/api-storys', '/api-game'];
|
|
const proxy = Object.fromEntries(
|
|
proxyPrefixes.map((p) => [
|
|
p,
|
|
{ target: PROXY_TARGET, changeOrigin: true, secure: true, ws: true },
|
|
])
|
|
);
|
|
|
|
return {
|
|
plugins: [react()],
|
|
server: {
|
|
// Bind IPv4 explicitly — Vite defaults to [::1] on Windows, which
|
|
// breaks IPv4 localhost (ECONNREFUSED from curl / browser).
|
|
host: '127.0.0.1',
|
|
port: 5173,
|
|
strictPort: true,
|
|
proxy,
|
|
},
|
|
build: {
|
|
outDir: 'build',
|
|
sourcemap: false,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
babylon: ['@babylonjs/core', '@babylonjs/loaders'],
|
|
colyseus: ['colyseus.js'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
define: {
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
|
|
},
|
|
};
|
|
});
|