react + electron 打包记录

package.json 中的更改:

增加:

  "homepage": "./",
 
  "build": {
    "productName": "xxxx",
    "appId": "com.xxx.win",
    "directories": {
      "output": "dist"
    },
    "files": [
      "dist/**/*",
      "public/**/*",
      "main.js",
      "package.json",
      "preload.js",
      "src/**/*"
    ],
    "win": {
      "target": [
        "nsis"
      ],
      "icon": "public/256.ico"
    },
   
    "nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowElevation": false,
      "allowToChangeInstallationDirectory": true,
      "installerIcon": "public/256.ico",
      "uninstallerIcon": "public/256.ico",
      "installerHeader": "public/background.png",
      "installerHeaderIcon": "public/256.ico",
      "createDesktopShortcut": true,
      "createStartMenuShortcut": true,
      "shortcutName": "xxx"
    }
 
 
安装 打包工具:npm install electron-builder --save-dev
 
main.js 和 preload.js 放到 public 目录下,并且把 main.js 名字改为 electron.js
 
 
 
打包指令:
    "electron-start": "electron .",
    "dist": "electron-builder --win --ia32",
    "distmac": "electron-builder --mac"
posted @ 2023-10-18 18:46  我喜欢喝糖水  阅读(36)  评论(0编辑  收藏  举报
我喜欢喝糖水的博客友链:股票指标编程学习