39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
/**
|
|
* One-off script to generate PWA icons from logo.png.
|
|
* Run: bun run scripts/generate-icons.ts
|
|
*/
|
|
import sharp from "sharp";
|
|
import { resolve } from "node:path";
|
|
|
|
const src = resolve(import.meta.dir, "../website/public/logo.png");
|
|
const outDir = resolve(import.meta.dir, "../website/public/icons");
|
|
|
|
// 192x192
|
|
await sharp(src).resize(192, 192).png().toFile(resolve(outDir, "icon-192.png"));
|
|
console.log("✓ icon-192.png");
|
|
|
|
// 512x512
|
|
await sharp(src).resize(512, 512).png().toFile(resolve(outDir, "icon-512.png"));
|
|
console.log("✓ icon-512.png");
|
|
|
|
// 180x180 apple-touch-icon
|
|
await sharp(src).resize(180, 180).png().toFile(resolve(outDir, "apple-touch-icon.png"));
|
|
console.log("✓ apple-touch-icon.png");
|
|
|
|
// Maskable 512x512: logo centered in inner 80% (410px) on #0f172a background
|
|
const logoForMask = await sharp(src).resize(410, 410).png().toBuffer();
|
|
await sharp({
|
|
create: {
|
|
width: 512,
|
|
height: 512,
|
|
channels: 4,
|
|
background: { r: 15, g: 23, b: 42, alpha: 1 }, // #0f172a
|
|
},
|
|
})
|
|
.composite([{ input: logoForMask, gravity: "centre" }])
|
|
.png()
|
|
.toFile(resolve(outDir, "icon-maskable-512.png"));
|
|
console.log("✓ icon-maskable-512.png");
|
|
|
|
console.log("Done! Icons written to website/public/icons/");
|