chihab / dotenv-run

Seamlessly load environment variables. Supports cli, esbuild, rollup, vite, webpack, angular. ESM and Monorepos.
246 stars 17 forks source link

Loading variables from parent folders #24

Closed Maximaximum closed 1 year ago

Maximaximum commented 1 year ago

Hi! My angular app lives in a monorepo, and all the environment variables live in the monorepo root folder .env file. Is there a way to make ngx-env/builder load the variable values not from the Angular project root, but from a folder above (or any other custom file)? This is supported by dotenv itself, but does not seem to be supported by ngx-env/builder

chihab commented 1 year ago

Hi! Could you please provide some resource showing that the feature is supported by dotenv?

The only solution would be to walk up the parent directories until finding a .env file. When should the lookup stop though? Provide a root workspace path in a builder configuration?

A workaround would be to add a symlink to the root .env file from the application project.

chihab commented 1 year ago

The feature is now supported in v16.0.2, env files might be overridden if also present in the application folder once this #44 is merged