Replies: 1 comment 11 replies
-
Normally, you don't commit |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-goals
Background
Turborepo v2 made a push to strict mode by default. While this does help greatly with predictability and caching, it puts more burden on env variable management.
In apps where all available env variables share the same prefix, (e.g.
NEXT_
orVITE_
), this is still manageable via one or two wildcard"env"
entries.However, when projects use a variety of environment variables (without a single common prefix), there is currently no OOTB method of auto-tracking these in Turborepo as dependencies.
Two example scenarios:
PUBLIC_
prefix for non-sensitive vars)Outside of Turborepo, env variables are sometimes already tracked in a local
.env
files, sometimes including additional files such as.env.local
,.env.development
, etc. These provide not only defaults env values (which can still be overridden in CI/CD), but also serve as a place to list and document relevant env variables.At the moment, adding new env variables requires adding it to an existing
.env
file, and then not-forgetting-to-add it toturbo.json
config, too.This gets cumbersome and error-prone quickly, especially if
"env"
entries need to be listed multiple times in some, but not all, tasks (e.g.gen
andbuild
may depend on env vars, but notlint
,test
etc.).Proposal
Provide an opt-in feature that allows scanning env variables defined in one or more files (e.g.
.env
), and add them to the final or default list of"env"
dependencies.Potential config syntax (A):
Here,
$TURBO_DOTENV$
is a special placeholder, similar to"$TURBO_DEFAULT$
, and expands automatically at Turborepo-runtime. Whereas the latter expands into Turborepo's default input file patterns,$TURBO_DOTENV$
might expand into all env variables defined in local.env
files.Challenges:
dotEnv
property.Alternative config syntax (B):
Reviving the previously used
"dotEnv"
property from Turborepo v1. This property would define files to scan for environment variable definitions. Those files would be default-included in"inputs"
(no need to list them again), and the variables defined within would be default-included in"env"
. The"env"
property can still be overridden, or expanded via"$TURBO_DEFAULT$"
similar to"inputs"
.Challenges:
Beta Was this translation helpful? Give feedback.
All reactions