admin管理员组

文章数量:1295910

Can somebody explain to me how electron-builder config work? I can't understand 95% of the things. Everything bellow API is somehow confusing. There are 0 examples of actually how something should be added to the build object. I mean, look at a simple dev request: I want to create windows and linux build. I copy/paste-ed some code and I came out with the fillowing:

{
  "name": "Test",
  "version": "1.0.0",
  "author": "Test Ltd.",
  "description": "Test",
  "devDependencies": {
      ...
  },
  "build": {
    "appId": "Test",
    "extraFiles": {
      "from": "./build",
      "to": "./dist"
    },
    "win": {
      "icon" : "build/images/icon.ico",
      "target": ["portable"]
    },
    "linux": {
      "icon" : "build/images/icon.png",
      "target": ["pacman"]
    }
  },
  "scripts": {
    "pack": "build --dir",
    "dist": "build"
  }
}
  1. It creates only x64 windows package. In the dist folder there is a folder called win-unpacked and one .exe file. The linux package is not there. Why?
  2. How to specify the arch (x64, x32)?
  3. How to use the things bellow API? I understood only how WinBuildOptions work - I should write "win" in the "build" object of package.json.
  4. What is Squirrel Events? I red this, but can't understand it from plain text.
  5. Any remendations for a video guide for "How to create an installer for Windows with Electron/electron-builder?" or "How to create package for Linux and upload it online so people with Linux can download it with Electron/electron-builder?" I couldn't find any.

Can somebody explain to me how electron-builder config work? I can't understand 95% of the things. Everything bellow API is somehow confusing. There are 0 examples of actually how something should be added to the build object. I mean, look at a simple dev request: I want to create windows and linux build. I copy/paste-ed some code and I came out with the fillowing:

{
  "name": "Test",
  "version": "1.0.0",
  "author": "Test Ltd.",
  "description": "Test",
  "devDependencies": {
      ...
  },
  "build": {
    "appId": "Test",
    "extraFiles": {
      "from": "./build",
      "to": "./dist"
    },
    "win": {
      "icon" : "build/images/icon.ico",
      "target": ["portable"]
    },
    "linux": {
      "icon" : "build/images/icon.png",
      "target": ["pacman"]
    }
  },
  "scripts": {
    "pack": "build --dir",
    "dist": "build"
  }
}
  1. It creates only x64 windows package. In the dist folder there is a folder called win-unpacked and one .exe file. The linux package is not there. Why?
  2. How to specify the arch (x64, x32)?
  3. How to use the things bellow API? I understood only how WinBuildOptions work - I should write "win" in the "build" object of package.json.
  4. What is Squirrel Events? I red this, but can't understand it from plain text.
  5. Any remendations for a video guide for "How to create an installer for Windows with Electron/electron-builder?" or "How to create package for Linux and upload it online so people with Linux can download it with Electron/electron-builder?" I couldn't find any.
Share Improve this question edited Apr 19, 2017 at 11:11 Marin Takanov asked Apr 10, 2017 at 13:23 Marin TakanovMarin Takanov 1,1384 gold badges20 silver badges38 bronze badges 3
  • Hi Marin, I have same problem already couple of days, I couldn't understand how to configure electron builder to make my apps' installer... If you found any good articles please link it below. Thank you : ) – Vano Commented Jun 5, 2019 at 12:56
  • What most helped me was the answers bellow. I couldn't find any good articles/github of how to config the app. It's sad really. All I had in the end was windows installer. One thing I would like to mention here is that if you want you app to be updated, the user will have to uninstall the old app and install the new one. Back in 2017 I wanted the updates to be patch-like, but this was not supported. I don't know if they support this now. – Marin Takanov Commented Jun 7, 2019 at 7:38
  • Fast forward 6 years to today and the documentation still isn't helpful at all. – Franco Commented Aug 16, 2023 at 11:07
Add a ment  | 

2 Answers 2

Reset to default 4

Take a look a the api options in the github repo for electron-builder, which uses the windows build options and linux build options to work. The descriptions of each item are laid out next to the attribute/property of the config.

This is a contrived example, but should at least give the structure of how it should look for windows and linux:

    "build":{
        "appid":"yourid",
        "asar": true
        "linux":{
            "category": "...",
            "target": "..."
        },
        "win":{
            "target": "...",
            "certificateFile":"...",
            "publisherName": "..."
        }

    }

There is a multi platform build page you can review. Specifically, to target a certain arch, you use the mand line flags. From the documentation:

By default build for current platform and current arch. Use CLI flags --mac, --win, --linux to specify platforms. And --ia32, --x64 to specify arch.

Typically, this is specified as an npm script, and passed along that way when you run the electon-build mand. In terms of building on platforms and potentially missing information, please see this quote:

Don't expect that you can build app for all platforms on one platform.

There appears to be extra setup and configuration needed to develop a linux and windows version based on the specific OS you are using. I would look at what that page states in terms of dependencies.

To answer part of your question you can not package an app when you are not on the platform that you want to package for example if you are on window the electron-builder will package windows app based on the machine you are using configuration of win targets

For linux targets, see here. The remendation seems to be to build inside a docker container if you want to build for linux.

本文标签: javascriptElectron electronbuilder configStack Overflow