Set Electron favicon with electron-builder

Viewed 10167

I would like set new favicon in my Electron App and replace default Electron icon when my app is build.

I use electron-builder package. In the doc, i see the icons need to be placed in the build directory. So :

enter image description here

And when i build my app, i've this message :

Application icon is not set, default Electron icon will be used.

Anyone can help me ?

Part of my package.json :

  "scripts": {
    "postinstall": "install-app-deps && npmpd",
    "pre-build": "./node_modules/.bin/electron-rebuild",
    "build-bcrypt": "npm rebuild bcrypt --update-binary",
    "develop": "npm run private:compile -- --source-maps true && run-p -r private:watch private:serve",
    "test": "mocha -R spec --compilers js:babel-core/register test/**/*.spec.js",
    "lint": "eslint --no-ignore scripts app test *.js",
    "pack": "run-s private:clean private:compile private:build:all",
    "pack:mac": "run-s private:clean private:compile private:build:mac",
    "pack:win": "run-s private:clean private:compile private:build:win",
    "pack:linux": "run-s private:clean private:compile private:build:linux",
    "private:build:all": "build -mwl",
    "private:build:mac": "build --mac",
    "private:build:win": "build --win",
    "private:build:linux": "build --linux",
    "private:watch": "npm run private:compile -- --source-maps true --watch --skip-initial-build",
    "private:serve": "babel-node scripts/serve.js",
    "private:compile": "babel app/ --copy-files --out-dir build",
    "private:clean": "rimraf build",
    "private:cleandb": "rm -rf ./categories ./presentations ./slides ./users"
  },
  "build": {
    "win": {
      "icon": "build/icon.ico"
    }
  }
4 Answers

In package.json, under the win key, you also need to specify the icon path:

"build": {
  "win": {
    "icon": "build/app.ico"
  }
}

Had similar issue, i added directories to my build

    "build":{
    "directories": {
              "buildResources": "resources"
            }
}

and inside the directories folder i had my icon.ico file

I encounter same issue with you, since I also use build directory for my output, here is my configuration:

"build": {
   "directories":{
      "output": "build"
   },
   "mac": {
      "icon": "build/logo.icns",
   },
   "win": {
      "icon": "build/logo.png"
   }
},

instead of specifying your directory such as ./logo.png which make electron shows default Electron icon is used reason=application icon is not set

I managed to have my icon on windows with the following script in package.json:

"package-win": "electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=Company --version-string.FileDescription=CE --version-string.ProductName=\"Product\""
Related