const fs = require('fs'); const path = require('path'); // Read the SVG file const svgPath = path.join(__dirname, '../public/icons/icon.svg'); const svgContent = fs.readFileSync(svgPath, 'utf8'); // Icon sizes for PWA const sizes = [72, 96, 128, 144, 152, 192, 384, 512]; // Try to use sharp if available, otherwise create placeholder files async function generateIcons() { try { const sharp = require('sharp'); for (const size of sizes) { const outputPath = path.join(__dirname, `../public/icons/icon-${size}x${size}.png`); await sharp(Buffer.from(svgContent)) .resize(size, size) .png() .toFile(outputPath); console.log(`Generated: icon-${size}x${size}.png`); } // Generate favicon await sharp(Buffer.from(svgContent)) .resize(32, 32) .png() .toFile(path.join(__dirname, '../public/favicon.png')); console.log('Generated: favicon.png'); // Generate apple-touch-icon await sharp(Buffer.from(svgContent)) .resize(180, 180) .png() .toFile(path.join(__dirname, '../public/apple-touch-icon.png')); console.log('Generated: apple-touch-icon.png'); console.log('\nAll icons generated successfully!'); } catch (error) { if (error.code === 'MODULE_NOT_FOUND') { console.log('Sharp not found. Installing...'); const { execSync } = require('child_process'); execSync('npm install sharp --save-dev', { stdio: 'inherit' }); console.log('Sharp installed. Please run this script again.'); } else { console.error('Error generating icons:', error); } } } generateIcons();