Is there an idiomatic Nx…

less than 1 minute read

Is there an idiomatic Nx way to leverage build-time environment variables in web/React projects? For example, I’d like to read an API endpoint URL from the environment at build time. Storing them in environment.ts seems strange for multiple reasons (it gets checked into version control, we wouldn’t want someone deploying the app to have to edit that file, you can’t possibly include every potential config value, etc.). For a Node project, I assume I can just use dotenv or something (untested), but typically you have to configure webpack to pass on your specific environment variables for a web project. create-react-app reads anything prefixed with REACT_APP_, for example. Does such a mechanism exist in Nx?