build.mjs 822 B

123456789101112
  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. import { fileURLToPath } from 'node:url';
  4. const root = path.dirname(fileURLToPath(import.meta.url));
  5. const template = fs.readFileSync(path.join(root, 'site.template.html'), 'utf8');
  6. const font = fs.readFileSync(path.join(root, '../fmode-landing-20261027/assets/fonts/geist-latin-wght-normal.woff2')).toString('base64');
  7. const css = fs.readFileSync(path.join(root, 'site.css'), 'utf8').replace('__GEIST_FONT__', font);
  8. const js = fs.readFileSync(path.join(root, 'site.js'), 'utf8');
  9. const html = template.replace('/* INJECT_STYLES */', () => css).replace('/* INJECT_SCRIPT */', () => js);
  10. fs.writeFileSync(path.join(root, 'index.html'), html);
  11. console.log('Built standalone index.html: ' + Math.round(Buffer.byteLength(html) / 1024) + ' KB. No external requests.');