2

I’m using Electron Packager to package an app. I need to build multiple versions of the app that use the exact same code base, but with a couple of different config variables.

For example, I might want to build an app with different themes - a red and a blue version. To achieve this, I simply set a variable in main.js:

const theme = red;

I want to be able to define this variable in my package.json build scripts somehow, so that anybody compiling the app doesn’t have to manually go into the JS and do this by hand each time, opening up the possibility for human error / oversight.

My build scripts are as follows:

"scripts": {
    "build-red": "electron-packager . \"Electron Red\" --platform=mas --arch=x64 --out=../build/ --overwrite --tmpdir=false --icon=icons/icon-red.icns",
    "build-blue": "electron-packager . \"Electron Blue\" --platform=mas --arch=x64 --out=../build/ --overwrite --tmpdir=false --icon=icons/icon-blue.icns",
}

Is it possible to define some sort of config variable using an argument here, in the build script?

Alex
  • 1,051
  • 1
  • 12
  • 26

0 Answers0