From 33bad3cbf3832e40b0e2d02fe5c6fe295ce229d0 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 30 Jul 2024 11:19:33 -0600 Subject: [PATCH] (docs): Callout for using dotenv. (#8882) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description ### Testing Instructions --- .../using-environment-variables.mdx | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx b/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx index b63163de0c476..f0a4698761a42 100644 --- a/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx +++ b/docs/repo-docs/crafting-your-repository/using-environment-variables.mdx @@ -56,21 +56,21 @@ Turborepo needs to be aware your environment variables to account for changes in Turborepo automatically adds prefix wildcards to your [`env`](/repo/docs/reference/configuration#env) key for common frameworks. If you're using one of the frameworks below in a package, you don't need to specify environment variables with these prefixes: -| Framework | `env` wildcard | -| ---------------- | ----------------- | -| Astro | `PUBLIC_*` | -| Blitz | `NEXT_PUBLIC_*` | -| Create React App | `REACT_APP_*` | -| Gatsby | `GATSBY_*` | -| Next.js | `NEXT_PUBLIC_*` | -| Nitro | `NITRO_*` | -| Nuxt.js | `NUXT_*`, `NITRO_*`| -| RedwoodJS | `REDWOOD_ENV_*` | -| Sanity Studio | `SANITY_STUDIO_*` | -| Solid | `VITE_*` | -| SvelteKit | `VITE_*` | -| Vite | `VITE_*` | -| Vue | `VUE_APP_*` | +| Framework | `env` wildcard | +| ---------------- | ------------------- | +| Astro | `PUBLIC_*` | +| Blitz | `NEXT_PUBLIC_*` | +| Create React App | `REACT_APP_*` | +| Gatsby | `GATSBY_*` | +| Next.js | `NEXT_PUBLIC_*` | +| Nitro | `NITRO_*` | +| Nuxt.js | `NUXT_*`, `NITRO_*` | +| RedwoodJS | `REDWOOD_ENV_*` | +| Sanity Studio | `SANITY_STUDIO_*` | +| Solid | `VITE_*` | +| SvelteKit | `VITE_*` | +| Vite | `VITE_*` | +| Vue | `VUE_APP_*` | Framework inference is per-package. @@ -170,6 +170,12 @@ Using a `.env` file at the root of the repository is not recommended. Instead, w This practice more closely models the runtime behavior of your applications since environment variables exist in each application's runtime individually. Additionally, as your monorepo scales, this practice makes it easier to manage each application's environment, preventing environment variable leakage across applications. + + You may find it easier to use a root `.env` file when incrementally migrating + to a monorepo. Tools like [dotenv](https://www.npmjs.com/package/dotenv) can + load `.env` files from different locations. + + ### Use `eslint-config-turbo` [The `eslint-config-turbo` package](/repo/docs/reference/eslint-config-turbo) helps you find environment variables that are used in your code that aren't listed in your `turbo.json`. This helps ensure that all your environment variables are accounted for in your configuration.