diff --git a/.env.example b/.env.example index 57b08d7e..bf495ee6 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,3 @@ -# Environment Variables Template -# Copy this file to .env and fill in your values - -# Clerk Authentication -PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_example_key_here - -# Convex Database -PUBLIC_CONVEX_URL=https://example.convex.cloud +PUBLIC_CLERK_PUBLISHABLE_KEY=pk_something +CONVEX_DEPLOYMENT=dev:something +PUBLIC_CONVEX_URL=https://something.convex.cloud diff --git a/src/lib/components/providers.svelte b/src/lib/components/providers.svelte index 8d555cba..2122356a 100644 --- a/src/lib/components/providers.svelte +++ b/src/lib/components/providers.svelte @@ -2,16 +2,15 @@ import { ClerkProvider, GoogleOneTap } from 'svelte-clerk/client'; import { ModeWatcher } from 'mode-watcher'; import { setupConvex } from 'convex-svelte'; - import { PUBLIC_CLERK_PUBLISHABLE_KEY, PUBLIC_CONVEX_URL } from '$env/static/public'; // Props let { children } = $props(); // Setup Convex - setupConvex(PUBLIC_CONVEX_URL); + setupConvex(process.env.PUBLIC_CONVEX_URL || ''); - + {@render children()} diff --git a/vite.config.ts b/vite.config.ts index 2f222dba..c5cc9716 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,15 @@ import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; +import { defineConfig, loadEnv } from 'vite'; import tailwindcss from '@tailwindcss/vite'; -export default defineConfig({ - plugins: [tailwindcss(), sveltekit()] +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ''); + + return { + plugins: [tailwindcss(), sveltekit()], + define: { + 'process.env.PUBLIC_CONVEX_URL': JSON.stringify(env.PUBLIC_CONVEX_URL), + 'process.env.PUBLIC_CLERK_PUBLISHABLE_KEY': JSON.stringify(env.PUBLIC_CLERK_PUBLISHABLE_KEY) + } + }; });