#!/usr/bin/env node // Генерирует public/favicon.ico (32x32 PNG-in-ICO, как у Astro по умолчанию) // и public/apple-touch-icon.png (180x180) из public/favicon.svg. import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import sharp from 'sharp'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..'); const svgPath = path.join(ROOT, 'public/favicon.svg'); const svg = fs.readFileSync(svgPath); const targets = [ { out: 'public/favicon.ico', size: 32 }, { out: 'public/apple-touch-icon.png', size: 180 }, ]; for (const { out, size } of targets) { const dst = path.join(ROOT, out); await sharp(svg, { density: 384 }) .resize(size, size) .png({ compressionLevel: 9 }) .toFile(dst); const kb = (fs.statSync(dst).size / 1024).toFixed(1); console.log(`wrote ${out} (${size}x${size}) — ${kb} KB`); }