#🤯 Dynamically import as an static import.
1 messages · Page 1 of 1 (latest)
for example, I want to have different providers for a database, if my config has
{"provider":"supabase}
I would like to use
import database_service from '$lib/providers/supabase/database
If {"provider":"pocketbase}
I would like
import database_service from $lib/providers/pocketbase/database
As you see is just a parameter in the path but seems like I have to use dynamic imports which are a pain as it cascades and now all my code is async and... it's too much for me. I could hardcode those but maybe there is a solution in vite/sveltekit, most likely vite.
Sorry, but I'm reposting from the svelte discord as is most likely something I can achieve with vite.
maybe with this https://vitejs.dev/config/#using-environment-variables-in-config
somebody has to stop me...
I've done an alias in svelte.config.js which is "conditional" as it takesthe value from referencing a custom config file.
I've done also a preinstall script in the package.json that add dependencies based on the same config file. Please stop me now.