Ratatoskr/scripts/preview-config.js
Nibu 4afd37e7dd preview: hash router and base-relative manifest link
Previews are static dirs with no SPA fallback; a reload or shared link on
/login/matrix.org was an nginx 404. preview-config now enables the hash
router, and index.html's manifest link follows the base path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 20:25:02 +00:00

15 lines
951 B
JavaScript

// Preview builds: set the background scene tier in dist/config.json (default 'low'); config.json
// in the repo stays 'off'. Previews are static directories with no SPA fallback, so they also switch
// to the hash router: a reload on /login/matrix.org would otherwise be an nginx 404. Usage: node scripts/preview-config.js [tier] [style]
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const tier = process.argv[2] ?? 'low';
const style = process.argv[3];
const file = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'dist', 'config.json');
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
config.hashRouter = { enabled: true, basename: '/' };
config.backgroundScene = { ...config.backgroundScene, tier, ...(style ? { style } : {}) };
fs.writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`);
console.log(`${file}: backgroundScene.tier = ${tier}${style ? `, style = ${style}` : ''}`);