相比較於electron-packager打包,使用electron-builder打包使得包體積更小。在electron-builder中,對於NSIS的配置,也是支持的node
electron-builder中nsis如何設置:https://www.electron.build/configuration/nsis數組
本片文章,將會詳細闡述幾點須要注意的地方。app
1,electron-builder打包路徑和開發路徑不一致。electron
2,electron-builder打包中若須要對專門的文件有讀寫的權限,則應將文件加入到asarUnpack數組中 。ui
3,在「build」屬性中須要設置一個屬性:"extends": null(具體緣由這方面尚未琢磨清楚),多是因爲NSIS自己的屬性,不須要去繼承。都是用戶自定義配置。spa
"build": {
"appId": "com.test", "asarUnpack": ["./test.txt","./test.ico" ], "files": [ "./main.js", "./build${/*}",
"./node_modules${/*}", "./src${/*}", "./public${/*}","./test.ico",
"./test.txt"
], "win": { "target": [ "nsis", "zip" ], "icon": "./satellite.png" }, "nsis": { "oneClick": false, "allowElevation": true, "allowToChangeInstallationDirectory": true, "installerIcon": "./test.ico", "uninstallerIcon": "./test.ico", "installerHeaderIcon": "./test.ico", "createDesktopShortcut": true, "createStartMenuShortcut": true, "perMachine": true,"unicode": true }, "extends": null }
以上是關於build的完整配置,從配置中,能夠看到,咱們須要對「test.txt」進行操做,因此將,這個文件放到asarUnpack下。code