Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

generate-icons.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const sharp = require('sharp');
  2. const fs = require('fs');
  3. const path = require('path');
  4. const sizes = [
  5. { size: 192, name: 'icon-192x192.png' },
  6. { size: 256, name: 'icon-256x256.png' },
  7. { size: 384, name: 'icon-384x384.png' },
  8. { size: 512, name: 'icon-512x512.png' },
  9. { size: 96, name: 'icon-96x96.png' },
  10. { size: 72, name: 'icon-72x72.png' },
  11. { size: 128, name: 'icon-128x128.png' },
  12. { size: 144, name: 'icon-144x144.png' },
  13. { size: 152, name: 'icon-152x152.png' },
  14. ];
  15. const inputPath = path.join(__dirname, '../public/icon.svg');
  16. const outputDir = path.join(__dirname, '../public');
  17. // Generate icons
  18. async function generateIcons() {
  19. try {
  20. console.log('Generating PWA icons...');
  21. for (const { size, name } of sizes) {
  22. const outputPath = path.join(outputDir, name);
  23. await sharp(inputPath)
  24. .resize(size, size)
  25. .png()
  26. .toFile(outputPath);
  27. console.log(`✓ Generated ${name} (${size}x${size})`);
  28. }
  29. // Generate apple-touch-icon
  30. await sharp(inputPath)
  31. .resize(180, 180)
  32. .png()
  33. .toFile(path.join(outputDir, 'apple-touch-icon.png'));
  34. console.log('✓ Generated apple-touch-icon.png (180x180)');
  35. console.log('\n✅ All icons generated successfully!');
  36. } catch (error) {
  37. console.error('Error generating icons:', error);
  38. process.exit(1);
  39. }
  40. }
  41. generateIcons();