afterPack.js 736 B

12345678910111213141516171819202122232425
  1. const path = require('path')
  2. const { rcedit } = require('rcedit')
  3. exports.default = async function afterPack(context) {
  4. if (context.electronPlatformName !== 'win32') return
  5. const exePath = path.join(
  6. context.appOutDir,
  7. `${context.packager.appInfo.productFilename}.exe`
  8. )
  9. const iconPath = path.resolve(__dirname, '../resources/icon.ico')
  10. console.log(`[afterPack] Setting icon for ${exePath}`)
  11. await rcedit(exePath, {
  12. icon: iconPath,
  13. 'version-string': {
  14. ProductName: context.packager.appInfo.productName,
  15. FileDescription: context.packager.appInfo.productName,
  16. CompanyName: context.packager.appInfo.companyName || '',
  17. },
  18. })
  19. console.log('[afterPack] Icon embedded successfully')
  20. }