// Render the PNG app icons from apps/web/public/icon.svg with headless // Chromium (Playwright). Run after changing the SVG: node scripts/render-icons.mjs import { chromium } from '@playwright/test'; import { readFileSync } from 'node:fs'; const dir = new URL('../apps/web/public/', import.meta.url); const svg = readFileSync(new URL('icon.svg', dir), 'utf8'); const b64 = Buffer.from(svg).toString('base64'); // Maskable: full-bleed background, artwork inside the 80% safe zone. const maskable = ``; // Badge: white glyph on transparent (Android tints it). const badge = svg.replace(/]*\/>/, '').replaceAll('#3DDC97', '#FFFFFF'); const jobs = [ ['icon-192.png', svg, 192], ['icon-512.png', svg, 512], ['icon-maskable-512.png', maskable, 512], ['badge-96.png', badge, 96], ]; const browser = await chromium.launch(); const page = await browser.newPage(); for (const [name, src, size] of jobs) { await page.setViewportSize({ width: size, height: size }); await page.setContent(`${src}`); await page.screenshot({ path: new URL(name, dir).pathname, omitBackground: true }); } await browser.close(); console.log('icons written');