electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box

Home Page:https://www.electron.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: override configuration per target or allow specifying a platform more than once

mat-sz opened this issue · comments

  • Electron-Builder Version: 25.0.0-alpha.6
  • Node Version: 21.7.3
  • Electron Version: 30.0.1
  • Electron Type (current, beta, nightly): current
  • Target: macOS

I'm trying to build an app with native dependencies that require asarUnpack and to reduce the installer size I'd love to only package the exact dependencies I need.

Currently I have:

{
  "mac": {
    "target": {
      "target": "dmg",
      "arch": ["arm64", "x64"]
    },
    "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"],
    "artifactName": "${productName}-darwin-${arch}-${version}.${ext}",
    "category": "public.app-category.utilities"
  }
}

I'd propose the structure of the config file to either be changed to something like this:

{
  "platforms": [
    {
      "type": "mac",
      "target": {
        "target": "dmg",
        "arch": "arm64"
      },
      "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/*-arm64/**/*"],
      "artifactName": "${productName}-darwin-${arch}-${version}.${ext}",
      "category": "public.app-category.utilities"
    },
    {
      "type": "mac",
      "target": {
        "target": "dmg",
        "arch": "x64"
      },
      "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/*-x64/**/*"],
      "artifactName": "${productName}-darwin-${arch}-${version}.${ext}",
      "category": "public.app-category.utilities"
    }
  ]
}

...or allowing targets to override other configuration options:

{
  "mac": {
    "target": [
      {
        "target": "dmg",
        "arch": "arm64",
        "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/*-arm64/**/*"],
      },
      {
        "target": "dmg",
        "arch": "x64",
        "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/*-x64/**/*"],
      },
    ],
    "artifactName": "${productName}-darwin-${arch}-${version}.${ext}",
    "category": "public.app-category.utilities"
  }
}

If you're interested, I can contribute a PR to the project with those changes.