You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the latest Svelte Summit website I had to use environment variables and ran into some pretty rough DX. Cloudflare workers require environment variables to be supplied either via a wrangler.toml file or manually added using the wrangler CLI or the web interface. These environment variables are then available as top level variables in the script.
This presents a bit of a problem when developing applications as these variables are not available. To get around it you need to use some other way of storing environment variables. I ended up using a package called env-cmd to run dev/build and preview with. However, since you grab the variables from different places (process.env.X vs X) you end up having to write conditionals in your code to handle this.
I understand I can probably write some wrapping function around this, but I still need to define the variables in two places.
Describe the proposed solution
Ideally you would only need to keep your variables in one place and having a way to reach the variables in a consistent way would be great.
Alternatives considered
Using another adapter.
Importance
would make my life easier
Additional Information
Maybe there needs to be a bigger discussion around environment variables in general here. I'm really only familiar with CF adapter but I imagine there are probably other deploy targets that also handle variables differently.
The text was updated successfully, but these errors were encountered:
I actually have a similar issue with Vercel. I've not tried SvelteKit for comparison, but to deploy our Sapper apps I have multiple deployment configurations. It's fairly annoying. I wonder if we could do something clever with the toml/vercel config during deploy, like pulling in the required variables from .env and putting them into these configs (we already write some custom config for begin, for example).
Or maybe it's not for SvelteKit to solve. It's hard to tell!
Describe the problem
On the latest Svelte Summit website I had to use environment variables and ran into some pretty rough DX. Cloudflare workers require environment variables to be supplied either via a wrangler.toml file or manually added using the wrangler CLI or the web interface. These environment variables are then available as top level variables in the script.
This presents a bit of a problem when developing applications as these variables are not available. To get around it you need to use some other way of storing environment variables. I ended up using a package called
env-cmd
to run dev/build and preview with. However, since you grab the variables from different places (process.env.X vs X) you end up having to write conditionals in your code to handle this.Here's one I wrote for an email API key:
I understand I can probably write some wrapping function around this, but I still need to define the variables in two places.
Describe the proposed solution
Ideally you would only need to keep your variables in one place and having a way to reach the variables in a consistent way would be great.
Alternatives considered
Using another adapter.
Importance
would make my life easier
Additional Information
Maybe there needs to be a bigger discussion around environment variables in general here. I'm really only familiar with CF adapter but I imagine there are probably other deploy targets that also handle variables differently.
The text was updated successfully, but these errors were encountered: