8

I'm currently building a cross platform app with electron(-forge) for mac, linux and windows. I'm on mac and with npm run make the app gets packaged and built for mac.

Is there any way (flag in build command or something) to build the app on mac for linux and windows as well?

Thank you in advance for any help!

dan-koller
  • 218
  • 1
  • 4
  • 10

2 Answers2

5

Yes, it is possible as indicated in the Electron forge makers documentation:

  • Squirrel.windows You can only build the Squirrel.Windows target on a Windows machine or on a macOS /Linux machine with mono and wine installed
  • Deb (linux) You can only build the deb target on Linux or macOS machines with the fakeroot and dpkg packages installed.
  makers: [
    {
      name: '@electron-forge/maker-dmg',
      config: {
        icon: `${iconPath}.icns`,
      },
    },
    {
      name: '@electron-forge/maker-squirrel',
      config: {
        authors: 'YOU',
        iconUrl: 'https://your_site/favicon.ico',
        exe: `${BUILD_NAME}.exe`,
        name: BUILD_NAME,
      },
    },
    {
      name: '@electron-forge/maker-deb',
      config: {
        options: {
          bin: BUILD_NAME,
          maintainer: 'YOU',
          homepage: 'https://you home page',
        },
      },
    },
  ],

Personally, I run the build in a Gitlab CI.

This allows the Windows shared runners use rather than a docker (linux) image with Mono because that was causing me some problems on Windows execution.

For the mac part I register a gitlab runner on my machine before launching the publish phase on gitlab.

I think you can achieve the same result very quickly with Travis who already has mac and windows runners available.

I hope I helped you. Good luck

J4Y-M
  • 281
  • 1
  • 9
0

try execute the command with parameter:

npm run make -- --platform win32
npm run make -- --platform linux
npm run make -- --platform darwin