安装依赖
安装asar
# 项目内安装
# npm install asar --save-dev
# 全局安装:
npm install asar -g # electron加密
安装electron-build
# 项目内安装
# npm install electron-build --save-dev
# 全局安装:
npm install electron-build -g
项目配置
在package.json中配置
json文件中不能有注释
{
"name": "navigation",
"version": "1.0.6",
"description": "飞行终端",
"main": "main.js",
"scripts": {
"start": "electron .",
"build": "electron-builder --win " //添加打包命令
},
"repository": "",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "jsy",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^14.2.9"
},
"build": {
"productName": "飞行终端",
"appId": "test.navigation",
"copyright": "service@cloudcentury",
"directories": {
"output": "dist"
},
"nsis": {
"oneClick": false,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"installerIcon": "./img/icon.ico",
"uninstallerIcon": "./img/icon.ico",
"installerHeaderIcon": "./img/icon.ico",
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "飞行终端"
},
"extraResources": [ //自定义文件位置
{
"from": "./adb/", //在项目的跟路径的文件
"to": "../adb" //放到安装后根路径
}
],
"asar": true, //加密
"win": {
"icon": "./img/icon.ico",
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"artifactName": "飞行终端_${version}.${ext}"
}
},
"dependencies": {
"@electron/remote": "^2.0.8"
}
}
打包
npm run build
标签:npm,安装,electron,build,true,打包,icon
From: https://www.cnblogs.com/ziyue7575/p/17535621.html