Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross platform compling #168

Closed
zkcrescent opened this issue Nov 2, 2019 · 8 comments
Closed

cross platform compling #168

zkcrescent opened this issue Nov 2, 2019 · 8 comments

Comments

@zkcrescent
Copy link

how can I build windows version at macos with electron-nuxt? I'm a new electron user, thanks for your help.

@zkcrescent
Copy link
Author

problem resolved ! I found electron-builder.Plantform.WINDOWS.createTarget can create windows targets for cliOptions.targets

@nwittwer
Copy link

nwittwer commented Jan 26, 2020

@michalzaq12 Would love to know this as well. Trying to build for Windows and Mac while using a Mac. I tried the above, but wasn't able to get it working.

Ideally I'd be able to use the CLI commands from electron-builder, such as adding in -mw in an NPM script to build Mac and Windows. Or change my builder.config.js file to define which OS builds are created based on which OS I'm using.

Being able to use the multi-platform and publishing (-p in CLI) features of electron-builder are key for me.

@nwittwer
Copy link

nwittwer commented Feb 25, 2020

@michalzaq12 Any update on this one? Unclear how to achieve this with the programmatic API for electron-builder. Would be really helpful to have in the documentation.

@nwittwer
Copy link

Found this https://www.electron.build/#programmatic-usage, but still a few issues:

  • Have to modify the .electron-nuxt/index.js file because the publish and targets properties are not exposed to the builder.config.js file. Seems like it would be better to modify builder.config.js.
  • Not clear how to add multiple targets (Windows, Mac) to build for both platforms on Mac. Not currently possible to pass the typical arguments like --mac --windows through the build script.
  • @xpda-dev/electron-builder does not expose the Platform property, so it must be imported separately from electron-builder package. This is needed for Platform.OS.createTarget().

Could you advise how you would suggest to tackle this? Is it out of scope for your package?

Example to build just for Windows on Mac (.electron-nuxt/index.js):

const Platform = require('electron-builder').Platform
const builder = new ElectronBuilder({
  cliOptions: {
    config: path.join(__dirname, '../builder.config.js'),
    targets: Platform.WINDOWS.createTarget()
  }
})

Example to use Publish (.electron-nuxt/index.js):

require('dotenv').config() // Load GH_TOKEN from .env file
const builder = new ElectronBuilder({
  cliOptions: {
    config: path.join(__dirname, '../builder.config.js'),
    publish: 'always',
  }
})

@michalzaq12
Copy link
Owner

Hey @nwittwer, it is a little out of scope from this template.
Due to limitations explained here: https://www.electron.build/multi-platform-build, I advise to compile application only on target platform (using for example Travis service).
But I will try to add support to target switcher in the next template version.
When it comes to publish option, it should be still possbile using builder.config.js (https://www.electron.build/configuration/publish).

builder.config.js is the same as electron-builder.yaml desribed in electron-builder documentation

@michalzaq12 michalzaq12 pinned this issue Feb 26, 2020
@nwittwer
Copy link

@michalzaq12 Ok! And thanks for links.

Yes, it appears that having this in the builder.config.js for each platform you want will trigger the Publish option (as you mentioned: https://www.electron.build/configuration/publish)

mac: {
   publish: ['github']
},
win: {},
linux: {}

To follow up (and in case it might help others), I started going down the TravisCI route, and I put together some of the configuration needed to get this project working on it: https://gist.github.com/nwittwer/60aef18c9b4e9506534bdcc0e4a7c3f5. Let me know if you think it would make sense to add any of it to maybe the "Guides > Building notes" section of your documentation.

@michalzaq12
Copy link
Owner

@zkcrescent @nwittwer I added support for the CLI commands from electron-builder
https://michalzaq12.github.io/electron-nuxt/guide/#electron-builder-arguments-1-6-0
and created a dedicated github action for building and releasing cross-platform electron-nuxt apps.

🚀

@nwittwer
Copy link

@michalzaq12 Looks very detailed and relevant, thanks! I'll let you know once I have a chance to use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants