build.mjs 927 B

12345678910111213141516
  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 project = path.resolve(root, '../..');
  6. const read = (name) => fs.readFileSync(path.join(root, name), 'utf8');
  7. const tokens = ['src/styles.uikit.css', 'src/app/core/styles/_base.scss', 'src/app/core/styles/_palette.scss']
  8. .map((name) => fs.readFileSync(path.join(project, name), 'utf8').replace(/^@tailwind[^;]+;\s*/gm, ''))
  9. .join('\n');
  10. const html = read('preview.template.html')
  11. .replace('/* INJECT_STYLES */', () => tokens + '\n' + read('styles.css'))
  12. .replace('/* INJECT_MODEL */', () => read('model.js'))
  13. .replace('/* INJECT_APP */', () => read('app.js'));
  14. fs.writeFileSync(path.join(root, 'index.html'), html);
  15. console.log(`Built subscription review prototype: ${Math.round(Buffer.byteLength(html) / 1024)} KB; standalone; no platform requests.`);