import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const root = path.dirname(fileURLToPath(import.meta.url)); const project = path.resolve(root, '../..'); const read = (name) => fs.readFileSync(path.join(root, name), 'utf8'); const tokens = ['src/styles.uikit.css', 'src/app/core/styles/_base.scss', 'src/app/core/styles/_palette.scss'] .map((name) => fs.readFileSync(path.join(project, name), 'utf8').replace(/^@tailwind[^;]+;\s*/gm, '')) .join('\n'); const html = read('preview.template.html') .replace('/* INJECT_STYLES */', () => tokens + '\n' + read('styles.css')) .replace('/* INJECT_MODEL */', () => read('model.js')) .replace('/* INJECT_APP */', () => read('app.js')); fs.writeFileSync(path.join(root, 'index.html'), html); console.log(`Built subscription review prototype: ${Math.round(Buffer.byteLength(html) / 1024)} KB; standalone; no platform requests.`);