Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change app icon using electron-builder

I changed my app icon and for some reason I can not update the icon (currently has the icon of an electron).

Relevant modules I use:

 "electron-builder": "5.7.0",
 "electron-prebuilt": "^ 1.4.13"

my package.json:

    "build": {
        "appId": "com.siemens.dmv",
        "asar": true,
        "win": {
          "target": "squirrel",
          "icon": "./build/icon.ico",
          "title": "DigitalManufacturingViewer",
          "msi": true,
          "IconUrl": "data: image / png; base64, 
          AAABAyUAJSshACMLBAAeJRAAAw0VAAYPEQAFJzsAE // (long string)
}

I tried several orders without success, does anyone know what command I have to run?

like image 651
Tom Cohen Avatar asked Jan 21 '18 15:01

Tom Cohen


People also ask

How do you make an Electron app executable?

Create the Electron based Syncfusion Application as mentioned in this link. Then package the application using Electron Packager, once packing completed JS_Electron-win32-ia32 folder will be created with Electron package file.

What is Electron app builder?

¶ A complete solution to package and build a ready for distribution Electron app for macOS, Windows and Linux with “auto update” support out of the box. NPM packages management: Native application dependencies compilation (including Yarn support).

How does Electron builder work?

electron-builder is a CLI tool that helps us create multi-platform distributions for Electron applications. It supports macOS, Windows, and Linux targets out of the box. It supports multiple file formats for each of these platforms such as dmg , pkg , mas and, mas-dev for macOS.


2 Answers

Make icon.ico (for Windows and Linux) and icon.icns (for Mac) and place them in the build directory.

Remove the other "icon" properties from the config. the build directory is the default location where electron builder searches for the icons.

Also try updating the electron-builder version. The version you are using is about 2 years old. A lot of features and bugfixes related to icons have been made in the new versions.

like image 159
quantumkv Avatar answered Oct 18 '22 12:10

quantumkv


Electron Builder by default looks for assets in the build folder:

./build/
    background.png
    [email protected]
    icon.icns
    icon.ico
    icon.png

Icon names are listed in the docs: https://www.electron.build/icons

You can configure the build folder path in your package.json using:

{
  "name": "your-app",
  "version": "0.0.1",
  "build": {
    "files": [
      "custom/directory"
    ],
    "directories": {
      "buildResources": "custom/directory"
    }
  }
}

Make sure that files are copied using the files attribute. As mentioned in the configuration docs: https://www.electron.build/configuration/configuration#configuration

like image 39
Kim T Avatar answered Oct 18 '22 12:10

Kim T