'use strict'; const { app, BrowserWindow } = require('electron'); const fs = require('fs'); const path = require('path'); const OUT_DIR = path.join(__dirname, '..', 'build'); const OUT_PNG = path.join(OUT_DIR, 'icon.png'); const HTML = `
`; app.disableHardwareAcceleration(); app.whenReady().then(async () => { fs.mkdirSync(OUT_DIR, { recursive: true }); const win = new BrowserWindow({ width: 1024, height: 1024, show: false, webPreferences: { offscreen: true }, }); await win.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(HTML)); // Laisser le temps au canvas de rendre await new Promise(r => setTimeout(r, 200)); const dataUrl = await win.webContents.executeJavaScript('window._png'); const b64 = dataUrl.replace(/^data:image\/png;base64,/, ''); fs.writeFileSync(OUT_PNG, Buffer.from(b64, 'base64')); console.log('Icône générée →', OUT_PNG); app.quit(); });