// One-off generator, not part of the app's runtime or build. Run manually // whenever the icon design changes: // pnpm --filter @notizarr/web exec node scripts/generate-icons.mjs // Requires `sharp` (devDependency) — rasterizes the hand-written SVG // sources into the PNG sizes PWA manifests / iOS actually need. Output is // committed to public/icons/, so this script does not need to run in CI or // in the Docker build. import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises' import path from 'node:path' import { fileURLToPath } from 'node:url' import sharp from 'sharp' const scriptsDir = fileURLToPath(new URL('.', import.meta.url)) const outDir = path.resolve(scriptsDir, '../public/icons') async function render(svgPath, outPath, size) { const svg = await readFile(svgPath) await sharp(svg).resize(size, size).png().toFile(outPath) console.log(`wrote ${path.relative(scriptsDir, outPath)} (${size}x${size})`) } async function main() { await mkdir(outDir, { recursive: true }) const standard = path.join(scriptsDir, 'icon-standard.svg') const maskable = path.join(scriptsDir, 'icon-maskable.svg') await render(standard, path.join(outDir, 'icon-192.png'), 192) await render(standard, path.join(outDir, 'icon-512.png'), 512) await render(maskable, path.join(outDir, 'maskable-512.png'), 512) await render(maskable, path.join(outDir, 'apple-touch-icon.png'), 180) await copyFile(standard, path.join(outDir, 'favicon.svg')) console.log('wrote favicon.svg') await writeFile(path.join(outDir, '.gitkeep'), '') } main().catch((err) => { console.error(err) process.exit(1) })