在使用electron-builder 打包時的一些心得但願能夠幫助更多的人解決問題javascript
1、安裝 electron-builde 在此以前必須先安裝yarn 固然用npm也能夠只是網絡不太好vue
yarn add electron-builder --save-dev
2、配置package.jsonjava
{ "name": "crjgui", "version": "0.0.0", "author": "samtiger <2669667558@qq.com>", "description": "An electron-vue project", "license": null, "main": "./dist/electron/main.js", "scripts": { "build": "node .electron-vue/build.js && electron-builder", "build:dir": "node .electron-vue/build.js && electron-builder --dir", "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", "dev": "node .electron-vue/dev-runner.js", "e2e": "npm run pack && mocha test/e2e", "pack": "npm run pack:main && npm run pack:renderer", "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", "test": "npm run unit && npm run e2e", "unit": "karma start test/unit/karma.conf.js", "postinstall": "" }, "build": { "productName": "出國(境)證件管理系統", //項目名稱 "appId": "org.simulatedgreg.electron-vue", //包名 "copyright":"航星永志版權全部", //版權全部 "directories": { "output": "dist" //輸出文件夾 },
"files": [ "dist/electron/**/*" ], "dmg": { "contents": [ { "x": 410, "y": 150, "type": "link", "path": "/Applications" }, { "x": 130, "y": 150, "type": "file" } ] }, "mac": { "icon": "build/icons/icon.icns" }, "win": { "icon": "build/icons/icon.ico", "target": [ { "target": "nsis", "arch": [ "ia32" ] } ] }, "linux": { "icon": "build/icons" } }, "dependencies": { ... }, "devDependencies": { ... } }
3、把installer.nsh 文件放到指定位置 也就是 在 nsis 下 include 的位置node
demo地址:https://gitee.com/chengxiang666/electron-builderDemo/tree/masterlinux