feat(pwa): add icon generator script with sharp

This commit is contained in:
Andrej Spielmann
2026-03-26 14:52:46 +01:00
parent 16c6b9789f
commit 830908d132
3 changed files with 23 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');
const svgPath = path.join(__dirname, 'public/icon-192.svg');
if (!fs.existsSync(svgPath)) {
console.error('SVG template not found at', svgPath);
process.exit(1);
}
const svgBuffer = fs.readFileSync(svgPath);
Promise.all([
sharp(svgBuffer).resize(192, 192).png().toFile(path.join(__dirname, 'public/icon-192.png')),
sharp(svgBuffer).resize(512, 512).png().toFile(path.join(__dirname, 'public/icon-512.png')),
sharp(svgBuffer).resize(180, 180).png().toFile(path.join(__dirname, 'public/apple-touch-icon.png')),
sharp(svgBuffer).resize(384, 384).extend({ top: 64, bottom: 64, left: 64, right: 64, background: { r: 27, g: 26, b: 85, alpha: 1 } }).png().toFile(path.join(__dirname, 'public/icon-maskable.png'))
]).then(() => {
console.log('Icons created successfully');
}).catch((err) => {
console.error('Icon generation failed:', err);
});