-
-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement built-in .env
support
#3747
Comments
How about supporting vite's files? I think multiple files are almost required if you have default vars checked in git and then have another file to override those vars at build time. If the same files as vite could be supported, it'd be some nice compatibilty. |
Yeah 👍 |
@alexander-akait I want to do this 🚀 |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
@webpack-bot keep open. |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
@alexander-akait, it looks like this feature was close to completion in #3759 but was closed due to inactivity. Could I perhaps submit a new PR picking up from where it was left off previously? |
@Sakib25800 Yes, you can |
To be honestly not sure we really need this right now, because we have https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs, I think we need update our docs and that's enough, we provice an example how to use them in And both things already work good, but only for So let's update documentation and that's all |
@snitin315 Do we have example to how to using |
Node's dotenv support is limited to a single file though. Often it's desirable to support two files, one checked into git, and one not. Vite does support Also https://github.com/motdotla/dotenv-expand is a very useful addon that is not supported by node's loader. |
From docs:
So you can use Yes, it's a bit wordy. But it works.
Node.js team is working on it, so I think it will be implemented in the near future. Also we have https://nodejs.org/dist/latest-v22.x/docs/api/process.html#processloadenvfilepath |
Ah great. I wasn't following the feature recently, this must've been a new addition I've missed. In that case. I think it should be fine to rely on that feature and not re-implement it. |
Yeah I think so, anyway providing them in |
For me both ways work, but I guess the general userbase would appreciate not having to touch |
@silverwind Yeah, it sounds good for me too, should be not hard to implement, we need to implement If
If it is string/multiple string we try to load them in order. Also make sense to have
So yes, PR welcome And also there are more options - https://github.com/mrsteele/dotenv-webpack?tab=readme-ov-file#properties, but I don't think we really need them all (they maybe implement like a features too) |
Not necessarily, I think i'd even be against the user being able to specify filenames, as this part is unconfigurable in vite too, it always loads the same 4 files. |
Yeah, but it loads env variables only for configuration file, if we need to pass them to runtime code we need to use Using My idea is implement the same logic (using |
@alexander-akait / @silverwind To clarify, my understanding is:
Let me know if I've understood correctly so I can work on it |
@Sakib25800 Yes, that is a minimum logic we need right now |
I think we need to implement built-in
.env
support, there is a good plugin https://github.com/mrsteele/dotenv-webpackDescribe the solution you'd like
Allow to red env variables from
.env
file and control it using CLI optionDescribe alternatives you've considered
No need
Additional context
No need
The text was updated successfully, but these errors were encountered: