fix(build): configurable base prefix and relative mesh_dir for /play/ hosting
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -35,6 +35,12 @@ export async function loadKinematics(url) {
|
||||
const r = await fetch(signed(`${url}?v=${MESH_VERSION}`), { cache: "force-cache" });
|
||||
if (!r.ok) throw new Error(`kinematics fetch ${r.status}`);
|
||||
const k = await r.json();
|
||||
// The exported mesh_dir is root-absolute ("/robot/mjlab/meshes"), which
|
||||
// breaks when the app is served under a prefix (/play/). Rebase it like
|
||||
// every other asset URL (MODEL_DIR is "./robot/mjlab").
|
||||
if (typeof k.mesh_dir === "string" && k.mesh_dir.startsWith("/")) {
|
||||
k.mesh_dir = `.${k.mesh_dir}`;
|
||||
}
|
||||
// Full-resolution meshes by default (the reduction will be redone
|
||||
// interactively in Blender later). `?lite=1` opts into a decimated
|
||||
// meshes-lite/ sibling if present.
|
||||
|
||||
@@ -2,6 +2,11 @@ import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
export default defineConfig({
|
||||
// Deploy prefix: "/" standalone (the HF Space), "/play/" when the bundle
|
||||
// is served under the Microduck Academy (VITE_BASE=/play/ npm run build).
|
||||
// Runtime asset URLs are base-relative ("./assets", "./policies") so
|
||||
// only the bundle references in index.html depend on this.
|
||||
base: process.env.VITE_BASE || "/",
|
||||
plugins: [react()],
|
||||
// MuJoCo WASM and onnxruntime-web stay on the CDN (dynamic import with
|
||||
// @vite-ignore in game/boot.js), exactly like the pre-Vite app: their
|
||||
|
||||
Reference in New Issue
Block a user