build-single.mjs 587 B

123456789
  1. import { readFile, writeFile } from 'node:fs/promises';
  2. const read = (filename) => readFile(new URL(filename, import.meta.url), 'utf8');
  3. const [html, css, script] = await Promise.all([read('index.html'), read('styles.css'), read('app.js')]);
  4. const bundled = html
  5. .replace('<link rel="stylesheet" href="styles.css" />', () => `<style>\n${css}\n</style>`)
  6. .replace('<script src="app.js"></script>', () => `<script>\n${script}\n</script>`);
  7. await writeFile(new URL('mobile-preview.html', import.meta.url), bundled, 'utf8');
  8. console.log('Built offline prototype: mobile-preview.html');