/* Generate favicon PNGs + manifest icons from favicon.svg (re-runnable). * * Usage (frontend container): * npm run icons * * Renders the SVG at each target size with sharp (no browser needed). * apple-touch-icon keeps the solid kirchenblau background (iOS fills * transparency black). The 512 icon doubles as maskable: the glyph stays * inside the inner 80% safe zone. */ import { readFileSync } from "node:fs"; import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; import sharp from "sharp"; const root = join(dirname(fileURLToPath(import.meta.url)), ".."); const svg = readFileSync(join(root, "public", "favicon.svg")); const targets = [ ["favicon-32x32.png", 32], ["apple-touch-icon.png", 180], ["icon-192.png", 192], ["icon-512.png", 512], ]; for (const [file, size] of targets) { await sharp(svg, { density: 300 }) .resize(size, size, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } }) .flatten({ background: file === "apple-touch-icon.png" ? "#1d4a79" : "#ffffff" }) .png() .toFile(join(root, "public", file)); console.log(`wrote public/${file}`); }