-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Env variables breaking build (even when comented) #1441
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
Comments
I just tested and could not reproduce this issue. The only difference is that I used |
Tried with For it to break there most be a For example: And even when I comment I have Ping me for any clarification |
I'm not quite following what you're saying. Can you provide a repo that reproduces this? |
This is related to #1396. Vite's 'define' plugin indiscriminately replaces environment variables without escaping quotes when doing its transform. Since the entire sourcemap is represented as a string that's delimited by quotes ("), the replaced map is invalid. Since comments are contained within the map, you would still get the error. |
I'm going to close this as a duplicate of #1396 |
Describe the bug
build
command breaking when addingimport.meta.env.VITE_MESSAGE
in the code, and still breaks even if the code is comented, I have to fully remove it for it to build.The
dev
command works fine.Tried without adapter and with
adapter-vercel
, but the problem percists.Logs
To Reproduce
(I was able to reproduce multiple times)
npm init svelte@next my-app
(all default)yarn
to install depencencies<h1>Hello, {import.meta.env.VITE_MESSAGE}</h1>
in./src/routes/index.svelte
.env
file (in root of the project) and addVITE_MESSAGE="World"
to ityarn build
Expected behavior
It should build.
Information about your SvelteKit Installation:
Diagnostics
npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
Tried without adapter and with
adapter-vercel
, but the problem percists.Severity
Seems pretty serious.
Additional context
The example is taken from the official FAQ env vars
The text was updated successfully, but these errors were encountered: