#How am I supposed to configure .env in a monorepo?

1 messages · Page 1 of 1 (latest)

viral ore
#

i think it only checks .env for current cwd, not the root (i wish it did tho)

slender vault
rustic estuary
#

I do this in my packages @brazen yoke

"dev": "bun with-env vinxi dev",
"with-env": "bun --env-file=../../.env --bun",```
slender vault
rustic estuary
slender vault
#

If you have maybe two child directories maybe. But if you ever end up needing more or changing it around, you're gonna have to change them all at some point

#

best practice regardless is to use --filter

rustic estuary
slender vault
#

bun --filter <pattern> <script>

rustic estuary
#

what does that have to do with envs?

slender vault
#

../../.env this specifically <- --filter will properly utilize any .env in the same working directory as the directories found in the pattern

rustic estuary
#

oh yeah, but he wanted just 1 .env no?

slender vault
#

and for any top level .env it will inherit below

#

Top level env will be the same in sub dirs, he’s got more than one package directory I would assume. If it’s undefined in pkg then it is then not top level.

#

Regardless I think your suggestion was not the best yes

viral ore
#

Personally, I just copy or simlink

slender vault