const sharp = require('sharp'); const fs = require('fs'); const path = require('path'); // 이미 /app/data 내에서 실행되므로 현재 디렉토리가 data 폴더임 const DATA_DIR = __dirname; const svgPath = path.join(DATA_DIR, 'icon.svg'); // icon.svg가 존재하는지 확인 if (!fs.existsSync(svgPath)) { console.error(`File not found: ${svgPath}`); process.exit(1); } const svgBuffer = fs.readFileSync(svgPath); async function convert() { try { console.log('Converting icons from:', svgPath); await sharp(svgBuffer).resize(64, 64).png().toFile(path.join(DATA_DIR, 'favicon.png')); await sharp(svgBuffer).resize(192, 192).png().toFile(path.join(DATA_DIR, 'pwa-192x192.png')); await sharp(svgBuffer).resize(512, 512).png().toFile(path.join(DATA_DIR, 'pwa-512x512.png')); await sharp(svgBuffer).resize(180, 180).png().toFile(path.join(DATA_DIR, 'apple-touch-icon.png')); console.log('Conversion complete. Files saved to:', DATA_DIR); } catch (err) { console.error('Error converting icons:', err); process.exit(1); } } convert();