import sharp from 'sharp'; import { readFile } from 'node:fs/promises'; const brand = (await readFile(new URL('../public/logo.svg', import.meta.url), 'utf8')) .replace(/<\?xml[^>]*\?>/, '').replace(/]*>/, '').replace(/<\/svg>\s*$/, ''); for (const [name, size, inset] of [['icon-192.png', 192, 15], ['icon-512.png', 512, 15], ['icon-maskable.png', 512, 25], ['apple-touch-icon.png', 180, 15]]) { const side = 100 - inset * 2; const svg = `${brand}`; await sharp(Buffer.from(svg)).resize(size, size).png().toFile(new URL(`../public/${name}`, import.meta.url).pathname); } console.log('RideBus PWA icons generated');