Files
beStream/scripts/generate-icon-svg.js
2025-12-31 20:57:03 +01:00

26 lines
867 B
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = path.join(__dirname, '..');
const iconPngPath = path.join(rootDir, 'public', 'icon.png');
const iconSvgPath = path.join(rootDir, 'public', 'icon.svg');
// Read the PNG file and convert to base64
const pngBuffer = fs.readFileSync(iconPngPath);
const base64Image = pngBuffer.toString('base64');
// Create SVG that embeds the PNG
const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512">
<image width="512" height="512" xlink:href="data:image/png;base64,${base64Image}"/>
</svg>`;
// Write the SVG file
fs.writeFileSync(iconSvgPath, svgContent);
console.log('✓ Generated icon.svg from icon.png');