Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

electron-builder - only build for mac but set to build mac and win

This is the first time I am building electronjs app so most probably I don't know what I am doing.

I follow the instruction from the github and this. This is my package.json:

{
  "name": "ExampleApp",
  "productName": "ExampleApp",
  "version": "1.0.0",
  "description": "Fun app.",
  "license": "MIT",
  "repository": "user/repo",
  "author": {
    "name": "sooon",
    "email": "[email protected]",
    "url": "Example.com"
  },
  "build": {
    "appId": "com. Example.ExampleApp",
    "mac": {
      "target": "dmg",
      "icon": "build/icon.png"
    },
    "win": {
      "target": "nsis",
      "icon": "build/icon.png"
    }
 },
  "scripts": {
    "test": "xo",
    "start": "electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder"
  },
  "dependencies": {
    "electron-debug": "^1.0.0",
    "jquery": "^3.3.1"
  },
  "devDependencies": {
    "devtron": "^1.1.0",
    "electron": "^1.8.2",
    "electron-builder": "^19.56.0",
    "electron-packager": "^8.7.2",
    "xo": "^0.18.0"
  },
  "xo": {
    "envs": [
      "node",
      "browser"
    ]
  }
}

As you can see I have mac and win in the build script. But when I run:

nom run dist

only DMG file (fully functional) is build. There is not trace of any work with win app. What had I miss out in the setting?

I am building this with my MacBook running on 10.12.6. Is it only you can build for your own platform? Can Mac build for Windows?

Update01 I took out:

"build": {
    "appId": "com.sooonism.pipidance",
    "mac": {
      "target": "dmg",
      "icon": "build/icon.png"
    },
    "win": {
      "target": "nsis",
      "icon": "build/icon.png"
    }
 },

from the package.json and it still build ok. That means the build script is located somewhere maybe?

like image 947
sooon Avatar asked Feb 09 '18 09:02

sooon


People also ask

Can I build Electron app for Mac on Windows?

On macOS/Linux you can build Electron app for Windows locally, except Appx for Windows Store (in the future (feel free to file issue) electron-build-service will support Appx target).

Does Electron work on Mac?

Compatible with Mac, Windows, and Linux, Electron apps build and run on three platforms.

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.


1 Answers

electron-builder defaults to building for the current platform. To build both, you need to do something like this in the "script", to build the mac and the window:

"dist-all": "electron-builder -mw"

like image 91
Jane Ku Avatar answered Oct 22 '22 19:10

Jane Ku