// Copies Cesium's runtime assets into static/ so they are served at /cesium/. // Cesium fetches Workers/Assets/Widgets/ThirdParty at runtime by URL (see // CESIUM_BASE_URL in src/app.html); they cannot be bundled by Vite. static/ is // copied verbatim in both dev and build, so this needs no Vite plugin. // Regenerated on every `npm install` via the prepare script. import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const root = join(dirname(fileURLToPath(import.meta.url)), '..'); const src = join(root, 'node_modules', 'cesium', 'Build', 'Cesium'); const dest = join(root, 'static', 'cesium'); if (!existsSync(src)) { console.error(`[copy-cesium] missing ${src} — is cesium installed?`); process.exit(1); } rmSync(dest, { recursive: true, force: true }); mkdirSync(dest, { recursive: true }); for (const dir of ['Assets', 'ThirdParty', 'Widgets', 'Workers']) { cpSync(join(src, dir), join(dest, dir), { recursive: true }); } console.log('[copy-cesium] assets copied to static/cesium/');