Can't Add Icon To Electron App With Electron Builder
"build":{
"productName":"yourProductName",
"appId":"org.yourProductName",
"dmg":{
"contents":[
{
"x":130,
"y":220
},
{
"x":410,
"y":220,
"type":"link",
"path":"/Applications"
}
]
},
"win":{
"target":[
"nsis",
"msi"
]
},
"linux":{
"target":[
"deb",
"rpm",
"snap",
"AppImage"
],
"category":"Development"
},
"directories":{
"buildResources":"resources",
"output":"release"
},
"files: ["resources/**/*"], // including buildResources folder in order to use this in the code
},"
I attached example electron-builder configuration that I configured for my project before. Please consider this part
"directories": {
"buildResources": "resources",
"output": "release"
}
buildResources
should include resource files like icons. If you are not going to set this buildResources
manually then the default will be build
.
output
is indicating where the packaged app will be after packaging and it's optional for your issue. Anyhow, I've set the project to generate release artifacts on the "release" folder.
In this project, I'm saving the icons in the project root directory like below. I don't know where your icon files are so I've attached the project structure that is working with this build configuration.
I Just went through your logs, I found the below error,
configuration.win has an unknown property 'title'. These properties are valid:
The title of the app should be given in productName
property. The title
keyword is invalid according to the document.
Also, I figured out there is buildResources
that is missing in the build configurations. I recommend using .ico
file for icons instead of png
images.
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder build"
},
"build": {
"productName": "Attendant",
"appId": "com.experiment.attendant",
"directories": {
"buildResources": "build"
},
"files": [
"build/**/*",
],
"win": {
"asar": false,
"target": "nsis",
"icon": "build/icon.ico"
},
"nsis": {
"installerIcon": "build/icon.ico",
"installerHeaderIcon": "build/icon.ico",
"deleteAppDataOnUninstall": true
},
}
For more configurations,
- Common Configurations
- Windows Configurations
See the working example for windows and Linux configurations. GITHUB