Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron: electron-builder config

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 recommendations 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.
like image 435
Marin Takanov Avatar asked Apr 10 '17 13:04

Marin Takanov


People also ask

What is appId Electron?

In simple terms, appId is a name that the client's computer is using to identify. This is particularly useful and you must've noticed it when you are trying to launch an app thar's already open, your OS would open the minimised version, rather than opening a new instance of the same app.

Does Electron forge use Electron-builder?

electron-builder nsis-web target for electron-forge. Recommended to build electron-forge project using electron-builder directly.


1 Answers

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 command 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 command. 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.

like image 150
unseen_damage Avatar answered Oct 06 '22 03:10

unseen_damage