Environmental variables with Vite? #774
Unanswered
jameschetwood
asked this question in
Q&A
Replies: 1 comment
-
I think you can just use Vite's Update your package.json script to e.g. "dev-marketing": "vite --mode marketing" you should now have that "mode === marketing" when you run Vite build/dev export default defineConfig(({ command, mode }) => {
console.log({ command, mode })
// 👆 can log to test output.
// fyi, `command` will be either dev or build (serve/build)
// in case you have different logic when building vs when just dev-ing
}) hope that helps! 🚀 ps: if you need to use env vars, use something like cross-env. I think. you should be able to do something like this (not tested): "dev-marketing": "cross-env VITE_MARKETING=yes vite" ref: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can you send environmental variables via different npm scripts in Vite?
I was hoping to do something like this:
Beta Was this translation helpful? Give feedback.
All reactions