Files
myrzx_bot/frontend/scripts/publish-console.mjs
T

12 lines
657 B
JavaScript

import { readFile, writeFile } from 'node:fs/promises';
const output = new URL('../../ranch_web/static/', import.meta.url);
const built = (await readFile(new URL('console/index.html', output), 'utf8')).replace(/\r\n?/g, '\n');
await writeFile(new URL('console/index.html', output), built, 'utf8');
const html = built.replaceAll(/(["'])\.\/assets\//g, '$1/static/console/assets/');
if (!html.includes('name="ranch-web-base-path"')) {
throw new Error('The runtime base-path metadata is missing from the console entry.');
}
await writeFile(new URL('index.html', output), html, 'utf8');
console.log('Published console entry to ranch_web/static/index.html');