electronelectron-builderelectron-updater

electron build time variables


I need to create two releases of my electron application:

  1. A silent installing exe where electron-updater is configured to automatically update in the background.
  2. An msi where the installed application does not automatically update, but just alerts the user that a new version has been released.

One way for me to do this would be to copy some sort of config into the build directory before I run electron-builder for each of the two builds, and read this config in the application to identify how to handle electron-updater events.

Before I do that I'm trying to identify whether that's the best way or not. Ideally I'd have a variable that I could send in to electron-builder that toggles the electron-updater functionality, but I don't think such a thing exists.

So the question really is:

Is it possible to use build-time variables with an electron application? If so, how?


Solution

  • A solution I came up with myself was to create a config.json file that I require-d into the js files I needed the data in.

    Part of my build process for different package types involved overwriting the config.js file with the build-specific version in the build directory before it was all packaged.

    This is not ideal, because it means that I can't build all of them with one electron-builder command, but as it happens I couldn't build the msi on my Mac anyway, so ended up issuing separate commands anyway.