Drizzle Kit dotenv support #3405
Replies: 7 comments 2 replies
-
Love it! Do we have a way to track when will this dotenv support land? |
Beta Was this translation helpful? Give feedback.
-
Why not use built-in Node.js features? |
Beta Was this translation helpful? Give feedback.
-
I'd advise against using |
Beta Was this translation helpful? Give feedback.
-
@AlexBlokh has the support been added? Because it doesn't seem to be working for me locally, even after adding @next/env. After adding @next/env, only .env, .env.local, .env.production and .env.production.local is detected. |
Beta Was this translation helpful? Give feedback.
-
Nice. It's working for me out of the box without a It'd be nice to update the Drizzle tutorials to reflect this 🙌 |
Beta Was this translation helpful? Give feedback.
-
In addition to this, using
It throws
Workaround is to do the following:
|
Beta Was this translation helpful? Give feedback.
-
Looking forward to this. Seems a little biased towards bun's behavior... which is fine, we're not all going to agree on everything 😄, though personally I'm currently more biased towards Vite's behavior since our project is built on SvelteKit, which is built on Vite. What concerns me the most is how all these tools we use (and drizzle-kit is just one of them) are each going to have their own subtle little differences in the way they do things, which ultimately means that different tools may end up with slightly different environment loaded — even though our .env files remain exactly the same in all cases! So honestly, the option I'm most excited about is this one: drizzle-kit --no-env #-> load custom/yourself I do like that most tools seem to be standardizing on having an tool-name --env-file-if-exists .env --env-file-if-exists .env.local --env-file-if-exists .env.$mode --env-file-if-exists .env.$mode.local … (to replicate Next.js's behavior, etc., you'd need a slightly different variation of this, but not much different) Of course no one is going to take the time or effort to write out all that every time they run a command! 🤦 So by this point, you may as well just prefix/wrap the command with I think an even better option than having to remember to prefix with We're doing this from our An example of when this subtle bug happens: We define This kind of subtle behavior can be tricky to even notice or figure out. And this is why I think the ability to opt out of any env loading by drizzle-kit with a I agree with @jbergstroem that it would be better to not use One limitation of using As the Vite docs point out, The only thing I don't like about Vite's loader is that there's no built-in way to set the mode via an environment variable. (They expect you to set the mode with In summary, the main advantage to this approach is that we get the exact same env loading behavior (automatic loading of the same 4 file patterns) across our whole project — no subtle but surprising differences in behavior between the various different tools used in the project (such as drizzle-kit). |
Beta Was this translation helpful? Give feedback.
-
As of now
drizzle-kit
config will be automatically supplied with.env
file via backed indotenv
package.In the next version kit will consume
.env*
files based onNODE_ENV
and will be compatible with Bun env consumption. Kit will not consume dotenv files when run in Bun, since Bun already does:we will read the following files automatically (listed in order of increasing precedence)
.env
.env.production
.env.development
.env.test
(depending on value ofNODE_ENV
).env.local
we will support variables expansion:
you will have an ability to provide custom env file or multiple files or tell Drizzle to not consume files automatically
drizzle-kit --env-file=.env.custom
drizzle-kit --env-file=.env.custom --env-file=.env.custom2
drizzle-kit --no-env
-> load custom/yourselfUPD 05.11.24:
pending Bun fix, for now we'll use
dotenvx
for every runtimeBeta Was this translation helpful? Give feedback.
All reactions