I know I am late for answering this question but I'll proceed anyway. I learned these things about the app's icon the hard way. I think this topic can be better understood by comparing the development and distribution phases.
Development phase
This is synonymous to running the app by npm start
.
During this phase you can never replace Electron's default icon -- no matter what piece of code you would add.
What's only possible is to put overlap icons on top of the default icon. However, it is probably not the solution you are looking for because it is not an icon replacement but just an overlay. This is what was documented about Icon overlays.
OP's above code is actually an example of the so called icon overlays.
win = new BrowserWindow({
width: 600,
height: 670,
icon: `${__dirname}/dist/assets/imgs/logo.png`
})
Furthermore, icon overlays can also be used to replace the notification icons.
Distribution phase
This is synonymous to using either of the following distribution frameworks:
- electron-forge
- electron-builder
- electron-packager
to create executable files (.app
/.exe
) for your application. It is in this phase where you can actually replace Electron's default icon.
In electron-packager for example, you can specify the icon you want to use during the packaging like so:
cd /path/to/app
# Mac (.icns)
npx electron-packager ./ --platform=darwin --icon=/path/to/your-custom-icon.icns
# Windows (.ico)
npx electron-packager ./ --platform=win32 --arch=x64 --icon=/path/to/your-custom-icon.ico
Doing it with electron-forge or electron-builder would be of different methods. I haven't tried them yet.
The whole point is... You can truly replace Electron's default icon only when packaging already your application.
electron-builder
, if you use CRA it somehow messes with the default icon detection so you need to disable the react-cra preset withextends: null
in the builder config. – Kippy