/** * Génère les PNGs d'icône PWA depuis `public/icon.svg`. * * Sort : * - public/icon-192.png (Android mostly, manifest) * - public/icon-512.png (Android, splashscreen) * - public/apple-touch-icon.png (iOS, 180×180 — recommandation Apple) * * À relancer si on touche au design de la gem : * pnpm --filter @rubis/web run icons */ import { readFile, writeFile } from 'node:fs/promises' import { fileURLToPath } from 'node:url' import { dirname, join } from 'node:path' import { Resvg } from '@resvg/resvg-js' const __dirname = dirname(fileURLToPath(import.meta.url)) const ROOT = join(__dirname, '..') const SRC = join(ROOT, 'public/icon.svg') async function render(size, out) { const svg = await readFile(SRC, 'utf-8') const resvg = new Resvg(svg, { fitTo: { mode: 'width', value: size }, background: '#FAF7F2', }) const buf = resvg.render().asPng() const dest = join(ROOT, 'public', out) await writeFile(dest, buf) console.log(`✓ ${out} (${size}×${size}, ${buf.byteLength.toLocaleString()} B)`) } await render(192, 'icon-192.png') await render(512, 'icon-512.png') await render(180, 'apple-touch-icon.png')