19

Can somebody please tell me the instructions for using a custom icon, when compiling an electron app (on mac) when using electron-forge package? Using --icon gives me an error:

error: unknown option `--icon'

What am I missing?

Will Stone
  • 4,626
  • 3
  • 21
  • 29

2 Answers2

55

Figured it out. Configure the path to your icon in your package.json.

Electron-Forge v5:

{
  ...
  "config": {
    "forge": {
      ...
      "electronPackagerConfig": {
        "icon": "path/to/icon.icns"
      },
      ...
    }
  }
}

Electron-Forge v6:

{
  ...
  "config": {
    "forge": {
      ...
      "packagerConfig": {
        "icon": "path/to/icon.icns"
      },
      ...
    }
  }
}
Will Stone
  • 4,626
  • 3
  • 21
  • 29
  • 11
    Thanks! Might be obvious to others, but this doesn't change the icon when running in `electron-forge start` – kevando Oct 19 '18 at 03:40
  • 2
    I can't find the documentation for this anywhere- can someone point to some (hopefully always-current) documentation link? (the larger question is: what are the parameters/constraints of this icon? etc...) – Phildo Apr 10 '19 at 18:51
  • 2
    @Phildo https://www.electronforge.io/configuration#packager-config although it is now documenting Version 6. – None Dec 10 '19 at 16:05
  • 1
    Hi all. I've updated my answer to show instructions for both v5 and v6. – Will Stone Dec 11 '19 at 09:10
  • 5
    Is this solution cross-platform? It seems macOS specific? Since `package.json` is shared by all platforms. I wonder how this could extend to Windows. – kakyo May 21 '20 at 10:56
  • Apparently, the electron app do not accept .icns. they only accept .ico icons. – Cadell Teng Jan 01 '21 at 04:24
  • 6
    @TengBangWei windows icons use `.ico` and macOS uses `.icns` – KetZoomer Jan 23 '21 at 00:15
  • 3
    Just remove the extension from the "icon" property as pointed out by @cris answer. And make sure you do have the proper files in place, e.g. icon.icns, icon.ico and icon.png. – Diogo Eichert Jun 10 '21 at 12:50
  • Is this a relative path to the config file? – LMS5400 Jun 21 '23 at 03:52
  • @LMS5400 yeah, that's what I have: https://github.com/will-stone/browserosaurus/blob/49cbd6409e0eeaa6754c93bfdd5387efe027d0c0/forge.config.ts#L15 – Will Stone Jun 22 '23 at 07:39
  • @WillStone, thanks, ya, it ended up working for me after a reboot. Looks like windows held the old icons around. – LMS5400 Jun 23 '23 at 16:27
8

Per the Options.icon documentation:

If the file extension is omitted, it is auto-completed to the correct extension based on the platform, including when platform: 'all' is in effect

Given that, set the value without extension:

"icon": "./assets/icon"

This is confirmed to work on both Windows and Mac.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Cris
  • 347
  • 3
  • 7