-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inherit Vite modes behaviour via --mode CLI argument #1258
Comments
Until something like this gets adopted, the solution I have been using is: # env.development - Vite.js defaults to "mode=development"
pnpm run dev
# env.staging
export MODE=staging && pnpm run build
# env.production - explicit override of svelte.config.js development default
export MODE=production && pnpm run build // svelte.config.js
import firebaseAdapter from 'svelte-adapter-firebase';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: firebaseAdapter({ firebaseJson: '../firebase.json' }),
target: '#svelte',
vite: {
// default to development as a guard
mode: process.env.MODE || 'development',
},
},
}; |
You can also use |
I think the In any case, 'only add new capabilities if they don't exist in userland' is a good general principle, so I'll close this issue. |
Is your feature request related to a problem? Please describe.
I want to have different environments/modes like staging/production/testing and pass some environment-related variables to the application.
Describe the solution you'd like
Vite already provides such functionality through "modes" and accepts --mode argument in CLI. Depending on the mode different .env files may be loaded and their contents passes as
import.meta.VITE_*
variables.I'd like Sveltekit to inherit this behaviour and pass --mode arg from CLI to Vite, instead of only limiting to development/production as it is now.
docs: https://vitejs.dev/guide/env-and-mode.html
Describe alternatives you've considered
How important is this feature to you?
Due to having some workarounds I don't think it's critical, but it would be convinient to use CLI arg instead of ENV vars + reading them in config.
The text was updated successfully, but these errors were encountered: