Specifying a --config ?

My existing build makes use of --config. (It is essentially a “white labelled app” - different app.config.js per customer). What would be my approach for specifying the correct app.config.js to the eas build command?

short answer

there aren’t affordances built in to eas build for this yet. one way you could do this is to use the eas-build-pre-install hook to replace your app config with the desired one. read about EAS Build-specific npm hooks.

long answer

in general i’d like to move away from us supporting the config flag in favor of app.config.js, and then developers can use environment variables to select which config file to load

// app.config.js

if (process.env.APP_CONFIG === 'dominos') {
  return require('./app-configs/dominos.json');
} else if (process.env.APP_CONFIG === 'pizza hut') {
  return require('./app-configs/pizzahut.json');

then rather than running expo publish --config app-configs/dominos.js it would be APP_CONFIG=dominos expo publish

do you think this would be a problem for you?

to address your question directly - at a very high level, eas build runs a build by:

  1. creating a local archive of the project, uploading that archive
  2. initialize a new vm from an image based on your eas.json config
  3. extracting the archive, installing deps, doing something similar to ejecting if in a managed project, and then building via fastlane/gradle
    (more in depth info on iOS build process - Expo Documentation and Android build process - Expo Documentation)

once we add support for environment variables, you would be able to handle your case by setting the appropriate environment variable for your build profile in eas.json. then when we do our “something similar to ejecting” on the build machine, we could pick the appropriate config to apply based on the logic in your app.config.js

I’m cool with any approach that allows me the flexibility of choosing a different config dynamically. Command-line arg or in-code config - no skin off my teeth either way. So the example app.config.js or a similar pattern is completely awesome!

From the rest of your reply it sounds like I’d be better off, for the time being, sticking to expo build.

I’m happy to be a guinea pig if there are some early releases or even a build-my-own from an eas-cli branch or whatnot. Just let me know when/how I could help out.

Thanks Brent!

1 Like