-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Describe the problem
Unless I'm missing something, there is currently no way to access $env/static/private outside of the Vite context, the file simply doesn't exist.
My database driver is defined in a file that's imported by SvelteKit code and a DB migration script. The latter is executed as a standalone CLI script using bun.
In the standalone execution context import.meta.env is defined but $env/static/private doesn't exist, and in the SvelteKit execution context it's the opposite. Is there a recommended way to deal with this?
My current solution:
const SOME_ENV_VAR = import.meta.env.SOME_ENV_VAR ?? (await import('$env/static/private')).SOME_ENV_VAR;Seems quite hacky and relies on top-level await but it works fine for my usecase.
Describe the proposed solution
Ideally, there would be a command in the svelte-kit CLI that runs a file in the Vite context.
Alternatives considered
No response
Importance
nice to have
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels