Electron Windows10打包小记

Electron镜像设置

1
2
3
4
5
# 设置永久镜像
# npm
npm config set registry https://registry.npm.taobao.org
# yarn
yarn config set registry https://registry.npm.taobao.org

安装Electron Builder

1
yarn add electron-builder --dev

基本配置

添加Electron-builder的配置项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"build": {
"appId": "myMusicPlayer",
"win": { // windows配置
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true
}
}

添加运行脚本

1
2
3
4
5
"scripts": {
"start": "chcp 65001 && nodemon --watch main.js --exec electron .",
"pack": "electron-builder --dir", // 新增,仅构建文件,不进行打包
"dist": "electron-builder" // 新增,构建文件并打包
},

在命令行中运行yarn dist进行打包