-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: add support for environment variables #581
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! The PR looks good!
I think that this solution does not work right now for the production server since for starting it we run cargo run --release
that by-passes the env set.
Also I couldn't understand if it is possible to manage all the env file expected by vite. I mean if I want to create a .env.staging
file. How can I use it?
Good work!
crates/tuono/src/env.rs
Outdated
let mode_name = match mode { | ||
Mode::Dev => "development", | ||
Mode::Prod => "production", | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have multiple environments.
I think the user could just define PROJECT_MODE
variable in its own .env
s to deal with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid point. I wrote this to correspond to vite modes, although that was the wrong decision. Staging env gives production mode from vite's table.
I think the user could just define PROJECT_MODE variable in its own .envs to deal with this
Can we use NODE_ENV
for that? (My brain is exploding with all these different variables 😅)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm from the doc looks like there are just two mode production
and development
. Maybe more are not necessary!
I'm not sure about NODE_ENV
since we are not using node... It might be misleading.
Thanks for your feedback. I will finish addressing in the morning. |
In terms of splitting the PR, here's my plan:
I think that would be quite nice, since each would be easy to revert without too much work. I read the atomic PRs article, and I think I agree - although I don't think it makes sense to split this into >4 PRs. WDYT? And one question - can we test stuff across TS and Rust with our E2E system or is that just TS? |
You can test both. Better using the About your plan:
|
Nice. Then integration can be done in the specific PRs for Rust and TS.
We can, I think it is a good idea because
It works although there are typescript errors. I don't have a fix for them yet.
Yep :) So just these three PRs then, and E2E done in the last PR because the point of that will be to check that all the PRs are consistent with each other.
E2E may not even be needed, I think we can cover it with unit and integration. |
So 4 tasks I'd say:
|
Alright. I'll leave this PR here as a proof of concept/reference, and I'll start work on each of those tasks in separate PRs. Since this will be quite a big addition, what do you want to do about releasing it? IMHO it may warrant a new minor release. |
I'm closing this, but I will keep the branch in my fork around for now. |
Checklist
Related issue
Fixes #570
Overview
Adds support for environment variables.
TUONO_PUBLIC_
prefix)Some kind of thing to prevent environment variables without(That is the user's job)TUONO_PUBLIC_
prefix from ever being sent clientsideNicely handle errors for when they are not set(That is the user's job).env.X
files in the same way as vite.env
files to default.gitignore
(See Add .env to .gitignore file generated in the starter code templates vitejs/vite#14380 for more context around my choice)