Electron Packager - set App Icons for OSX & Windows

大城市里の小女人 提交于 2019-12-03 16:25:27

问题


I am building my electron application with electron packager for windows and OSX platform.

package.json:

"build": "electron-packager . $npm_package_productName --out=dist --ignore='^/dist$' --prune --all --icon=icon.icns"

I run my build process with npm run build.

Question:

How can I use the electron packager script in my package.json to set the windows AND osx Icon?

Problem:

The above script sets the app icon for OSX only.
It doesnt set the icon for the windows app (NPM throws failure).

Solution:

I had to install wine on my OSX. Otherwise it is not possible to build the windows exe with the --icon tag. Why? Because electron-packager uses node-rcedit for that, which requires wine.

in my package.json:

"pack:osx": "electron-packager . $npm_package_productName --out=dist/osx --platform=darwin --arch=x64 --icon=assets/build/osx/icon.icns && npm run codesign",
"pack:win32": "electron-packager . $npm_package_productName --out=dist/win --platform=win32 --arch=ia32",
"pack:win64": "electron-packager . $npm_package_productName --out=dist/win --platform=win32 --arch=x64 --version=0.36.2 app-version=1.0 --icon=assets/build/win/icon.ico",
"build": "npm run pack:osx && npm run pack:win32 && npm run pack:win64"

npm run build to start the process..


回答1:


Solution:

I had to install wine on my OSX. Otherwise it is not possible to build the windows exe with the --icon tag. Why? Because electron-packager uses node-rcedit for that, which requires wine.

in my package.json:

"pack:osx": "electron-packager . $npm_package_productName --out=dist/osx --platform=darwin --arch=x64 --icon=assets/build/osx/icon.icns && npm run codesign",
"pack:win32": "electron-packager . $npm_package_productName --out=dist/win --platform=win32 --arch=ia32",
"pack:win64": "electron-packager . $npm_package_productName --out=dist/win --platform=win32 --arch=x64 --version=0.36.2 app-version=1.0 --icon=assets/build/win/icon.ico",
"build": "npm run pack:osx && npm run pack:win32 && npm run pack:win64"

npm run build to start the process..



来源:https://stackoverflow.com/questions/36941605/electron-packager-set-app-icons-for-osx-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!