From 830908d132fa303d7b42ee1b9775eee88eb22017 Mon Sep 17 00:00:00 2001 From: Andrej Spielmann Date: Thu, 26 Mar 2026 14:52:46 +0100 Subject: [PATCH] feat(pwa): add icon generator script with sharp --- frontend/generate-icons.js | 21 +++++++++++++++++++++ frontend/package-lock.json | 5 +---- frontend/package.json | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/frontend/generate-icons.js b/frontend/generate-icons.js index e69de29..99dfd92 100644 --- a/frontend/generate-icons.js +++ b/frontend/generate-icons.js @@ -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); +}); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0ce3a02..5e62f84 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -23,6 +23,7 @@ "react-big-calendar": "^1.19.4", "react-dom": "19.2.4", "shadcn": "^4.1.0", + "sharp": "^0.34.5", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.4.0", @@ -1055,7 +1056,6 @@ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", "license": "MIT", - "optional": true, "engines": { "node": ">=18" } @@ -4192,7 +4192,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "devOptional": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -8787,7 +8786,6 @@ "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", "hasInstallScript": true, "license": "Apache-2.0", - "optional": true, "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", @@ -8831,7 +8829,6 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", "license": "ISC", - "optional": true, "bin": { "semver": "bin/semver.js" }, diff --git a/frontend/package.json b/frontend/package.json index 3204923..0a9f3d6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -24,6 +24,7 @@ "react-big-calendar": "^1.19.4", "react-dom": "19.2.4", "shadcn": "^4.1.0", + "sharp": "^0.34.5", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.4.0",