Closed CerealKiller97 closed 1 year ago
I'm not familiar with SvelteKit at all but I think they use their own method to load environment variables so I guess the plugin is not compatible.
Let's say I replace your env.ts
with :
import { defineConfig, Schema } from "@julr/vite-plugin-validate-env";
export default defineConfig({
VITE_INSTAGRAM_CLIENT_ID: Schema.string(),
VITE_INSTAGRAM_CLIENT_SECRET: Schema.string(),
VITE_PUBLIC_SUPABASE_URL: Schema.string(),
VITE_PUBLIC_SUPABASE_ANON_KEY: Schema.string(),
});
And add the VITE_ prefix to all your variable in your .env
file
This should work.
However, it is likely that these variables are also injected into the client code. Which you don't want because some of them are sensitive data. Maybe you can try to verify
@Julien-R44 I've tried this way, didn't work, will explore more, I will go through SvelteKit plugin for Vite, will notify you If I find something interesting.
Tried on my side and it worked Feel to share a repo with the issue and I can take a look
@Julien-R44 I've tried it and it's working. Thank you once again!
Hello,
I've just seen this amazing plugin, and I wanted to put it in my SvelteKit project. I have read the docs a couple of times, and I am still getting the same issues, it says that my variables are not present but they are.
This is how my
.env
file looks like:I have extracted validation logic to
env.ts
file: