打包
-
安装electron-packager
npm i electron-packager -g npm i electron-packager --save-dev
-
编辑package.json “scripts”: { “start”: “electron .”, “build”: “electron-packager . MyFirstApp —ignore=node_modules/electron-* —platform=win32 —arch=x64 —version=0.32.3” } version 字段从 https://github.com/atom/electron/releases 这里查看得知
-
生成
npm run build
使用asar
-
安装asar
npm i asar -g npm i asar --save-dev
-
编辑package.json “scripts”: { “start”: “electron .”, “build”: “electron-packager . MyFirstApp —ignore=node_modules/electron-* —platform=win32 —arch=x64 —version=0.32.3”, “package”: “asar pack MyFirstApp-win32-x64/resources/app MyFirstApp-win32-x64/resources/app.asar && rm -rf MyFirstApp-win32-x64/resources/app” }
-
执行
npm run package