Electron uses the electron-builder tool packaging process

Posted May 27, 20201 min read

  1. Install electron-builder

    npm install electron-builder --save-dev

  1. Configure electron-builder related parameters in the project's package.json file
  • For specific parameters, please refer to the official documentation: https://www.electron.build/configuration/configuration

  • My own configuration is posted below:

    {

    "name":"electron-quick-start",
    "version":"1.0.0",
    "description":"A minimal Electron application",
    "main":"main.js",
    "scripts":{
      "start":"electron.",
      "build":"electron-builder"
    },
    "build":{
      "appId":"com.imaxue.app",
      "productName":"yangyi",
      "win":{
        "icon":"build/favicon.ico",
        "target":[
          "nsis"
       ]
      },
      "nsis":{
        "oneClick":false,
        "perMachine":true,
        "allowToChangeInstallationDirectory":true
      }
    },
    "repository":"https://github.com/electron/electron-quick-start",
    "keywords":[
      "Electron",
      "quick",
      "start",
      "tutorial",
      "demo"

    ],

    "author":"GitHub",
    "license":"CC0-1.0",
    "devDependencies":{
      "electron":"^ 8.2.5",
      "electron-builder":"^ 22.6.1"
    },
    "dependencies":{
      "bootstrap":"^ 4.5.0",
      "electron-store":"^ 5.1.1",
      "uuid":"^ 8.1.0"
    }

    }

  • Note that if there is a problem with the download source, you can add it in the build

      "electronDownload":{
        "mirror":"https://npm.taobao.org/mirrors/electron/"
      },

  1. Execute the packaging command

    npm run build

  1. Finish

After completion, the dist directory will be generated under the project directory