diff --git a/templates/app/favicon.ico b/templates/app/favicon.ico index eba9735..c71d302 100644 Binary files a/templates/app/favicon.ico and b/templates/app/favicon.ico differ diff --git a/templates/dev/icons/favicon.png b/templates/dev/icons/favicon.png new file mode 100644 index 0000000..51ee3da Binary files /dev/null and b/templates/dev/icons/favicon.png differ diff --git a/templates/dev/icons/favicon.svg b/templates/dev/icons/favicon.svg deleted file mode 100644 index 54be162..0000000 --- a/templates/dev/icons/favicon.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/templates/dev/icons/make-favicon.js b/templates/dev/icons/make-favicon.js index f571cd7..f0dbd66 100644 --- a/templates/dev/icons/make-favicon.js +++ b/templates/dev/icons/make-favicon.js @@ -2,11 +2,18 @@ const fs = require('fs'); const path = require('path'); const sharp = require('sharp'); // npm install sharp --save-dev -const faviconSvgPath = path.join(__dirname, 'favicon.svg'); +const svgPath = path.join(__dirname, 'favicon.svg'); +const pngPath = path.join(__dirname, 'favicon.png'); const appOutputDir = path.join(__dirname, '..', '..', 'app'); const faviconSizes = [16, 24, 32, 48, 64, 128, 256]; +function detectSourceFile() { + if (fs.existsSync(svgPath)) return { filePath: svgPath, type: 'svg' }; + if (fs.existsSync(pngPath)) return { filePath: pngPath, type: 'png' }; + throw new Error('Aucun fichier favicon.svg ou favicon.png trouvé dans dev/icons/'); +} + function ensureDirectoryExists(directory) { if (!fs.existsSync(directory)) { fs.mkdirSync(directory, { recursive: true }); @@ -15,26 +22,29 @@ function ensureDirectoryExists(directory) { async function generateFavicon() { try { + const { filePath, type } = detectSourceFile(); + console.log(`Source détectée : ${type.toUpperCase()} (${path.basename(filePath)})`); + ensureDirectoryExists(appOutputDir); const tempPngs = []; for (const size of faviconSizes) { - const pngPath = path.join(appOutputDir, `favicon-${size}.png`); - await sharp(faviconSvgPath) + const outPath = path.join(appOutputDir, `favicon-${size}.png`); + await sharp(filePath) .resize(size, size) .png() - .toFile(pngPath); - console.log(`SVG → PNG (${size}x${size}) ✅`); - tempPngs.push(pngPath); + .toFile(outPath); + console.log(`${type.toUpperCase()} → PNG (${size}x${size}) ✅`); + tempPngs.push(outPath); } - await sharp(faviconSvgPath) + await sharp(filePath) .resize(256, 256) .toFile(path.join(appOutputDir, 'favicon.ico')); console.log('favicon.ico créé ✅'); - for (const pngPath of tempPngs) { - fs.unlinkSync(pngPath); + for (const p of tempPngs) { + fs.unlinkSync(p); } console.log('Génération du favicon terminée !');