This repository has been archived by the owner on Jul 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Use process ENVs also in template sections #60
Comments
what about <script>
let world = import.meta.env.VITE_WORLD;
</script>
<h1>Hello {world}</h1> Does that also cause an error? If you absolutely need to use import.meta.env in the template and believe this to be a bug please add a proper reproduction and error logs that show when/how this is happening. |
Yeah, using const is fine, but sometimes people use that ENVS in template sections, you know. |
The error message is directly from the svelte compiler. If you absolutely need this to work, bring it up on svelte discord. |
I think they fixed it today! sveltejs/svelte#5422 |
for the record. svite-0.7.1 has updated svelte peerDependency to 3.26.0. You should be able to use it |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Summary
Before Svite I was using
<div>{process.env.MY_ENV_FROM_FILE}</div>
.Now (because of this: https://github.com/vitejs/vite#modes-and-environment-variables) I have to use
import.meta.env.VITE_MY_ENV_FROM_FILE
and it works in JS code.But I need to use it also in my html sections, like this:
<div>{import.meta.env.VITE_MY_ENV_FROM_FILE}</div>
.But it doesn't work:
Cannot use 'import.meta' outside a module
.Proposed Solution
Use process ENVs also in template sections, please.
😄
The text was updated successfully, but these errors were encountered: