sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.4k stars 1.88k forks source link

More options to indicate public environment variable then simple publicPrefix #12375

Open xmlking opened 2 months ago

xmlking commented 2 months ago

Describe the problem

i like sveltekit support array for publicPrefix config. I have to deal with a vendor lib that expect public environment variables prefixed with NHOST* and rest used PUBLIC* . With current limitation, I have to define duplicate variables

my usecase : https://github.com/xmlking/spectacular/blob/916ef57220c6ef451dc9317e26201bb75a1641c3/.env.example#L42****

Describe the proposed solution

While using some 3rd party service provides ( CMS, Backend-as-a-Service, payment systems) with SvelteKit, we have to use vender provided libraries to interact with their system, sometime they have some Convention-over-configuration to use environment variables that are prefixed with certain text (e.g., NHOST, VERCEL etc) . If those environment variables are needed on both client-side as well as server-side, we have to duplicate them once with vendor prefix and PUBLIC_which leads to duplication. It will be nice to allow multiple patterns/prefixes to indicate public variables in SvelteKit to support such use-cases.

Alternatives considered

Inspired from Astro astro:env , methodology described here seams more flexible https://astro.build/blog/astro-4100/

Importance

nice to have

Additional Information

Ref https://x.com/xmlking/status/1803533098170327073?s=61&t=prjj5Lm6MXpnSZaenY1B-A

benmccann commented 2 months ago

What if the prefix could accept an array so that you could specify both PUBLIC and NHOST?

xmlking commented 2 months ago

What if the prefix could accept an array so that you could specify both PUBLIC and NHOST?

Yes that could solve my needs