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

sooon picture sooon · Feb 9, 2018 · Viewed 8.1k times · Source

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?

Answer

Jane Ku picture Jane Ku · Jul 9, 2018

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"