用电子助剂设置Electron favicon

时间:2017-11-13 11:17:15

标签: node.js electron electron-builder

我想在我的Electron App中设置新的favicon,并在我的应用程序构建时替换默认的Electron图标。

我使用electron-builder包。在文档中,我看到图标need to be placed in the build directory.所以:

enter image description here

当我构建我的应用程序时,我收到了这条消息:

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

任何人都可以帮助我?

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"
    }
  }

3 个答案:

答案 0 :(得分:1)

有类似的问题,我在构建中添加了目录

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

在目录文件夹中,我有icon.ico文件

答案 1 :(得分:0)

package.json中,在win键下,您还需要指定图标路径:

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

答案 2 :(得分:0)

我设法在Windows上使用以下脚本在 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\""