electron 打包
electron 打包
主流electron打包方式有electron-packager和electron-builder,本篇使用electron-builder打包;
- 官方推荐使用yarn
一,它可以更好地处理依赖关系。
二,可以使用 yarn clean 帮助减少最后构建文件的大小。
安装 npm install -g yarn --registry=https://registry.npm.taobao.org - 安装 electron 以及 electron-builder
yarn add electron electron-builder -D
这里使用版本信息
- 配置build
常用配置"build": { // electron-builder配置 "productName":"xxxx",//项目名 这也是生成的exe文件的前缀名 "appId": "com.xxxxx",//包名 "copyright":"xxxx",//版权 信息 "compression": "store", // "store" | "normal"| "maximum" 打包压缩情况(store 相对较快),store 39749kb, maximum 39186kb "directories": { "output": "build" // 输出文件夹 }, "electronDownload": { "mirror": "https://npm.taobao.org/mirrors/electron/" // 下载源 改为淘宝镜像 }, "asar"