Flag to load .env file during local builds
K
KendallRoth
While the Expo CLI automatically detects and loads a local .env file during its execution, unfortunately the EAS CLI does not while performing local builds. It would be nice to have a build flag to detect and use a local.env file during local builds, since local builds have no access to EAS Secrets. The alternative is always specifying all secrets in the argument before the rest of the build command, which is frustrating over time. Since Expo CLI automatically detects build variables, doing the same via local EAS Build would be appreciated.
Brent Vatne
if you include your .env file in your eas build archive (https://expo.fyi/eas-build-archive) it will be loaded by expo cli and env vars will be available to metro and for app config evaluation. please note that expo cli .env integration does not load .env outside of that context. so, if you were to just run sentry-cli, for example, that would not source .env.
K
KendallRoth
Brent Vatne It would be nice to have a flag for local EAS Builds (only) that would allow reading a local .env file and sourcing it into the environment (ie. like Expo CLI), similar to how one can provide secrets to a remote EAS Build. Currently one can instead load the .env file manually into the local shell execution before running a local EAS Build; however, this is an additional step that seems feasible to move to a CLI flag. I recognize that including the .env file in a build archive would automatically pick it up; however, I believe that it's a best practice to keep secrets out of a committed file, which eliminates adding the .env file to the build archive (as best I understand). That being said, local EAS Builds are a wonderful addition to the suite of Expo tooling, and it feels like a small pain point with them could be addressed by optionally (via a flag) allowing automatically loading a .env file during execution (in addition to the typical pickup).
Wodin
KendallRoth Other possibilities:
* Add a script to
package.json
that sources .env
before running eas build
* Copy
.gitignore
to .easignore
and then remove .env
from .easignore
. See also: https://expo.fyi/eas-build-archive and https://expo.fyi/eas-vcs-workflowK
KendallRoth
Wodin Ah, I did not realize that if
.easignore
was present it would ignore the .gitignore
files; that may indeed work!