Electron Forge 为其他平台构建应用程序

Electronforge build app for other platform

我目前正在使用 electron(-forge) 为 mac、linux 和 windows 构建一个跨平台应用程序。我在 mac 并使用 npm run make 为 mac 打包和构建应用程序。

是否有任何方法(在构建命令中标记或其他)在 mac 上为 linux 和 windows 构建应用程序?

提前感谢您的帮助!

是的,如 Electron forge makers 文档中所述,这是可能的:

  • 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',
        },
      },
    },
  ],

就个人而言,我 运行 在 Gitlab 中构建 CI。

这允许 Windows shared runners 使用 Mono 而不是 docker (linux) 图像,因为这导致我在 Windows 执行时出现一些问题。

对于 mac 部分,我在 machine 上注册了一个 gitlab 运行ner,然后在 gitlab 上启动发布阶段。

我认为您可以通过已经有 mac and windows 运行 可用人员的 Travis 很快实现相同的结果。

希望对你有所帮助。祝你好运