access .env values in vite.config.js file? #2260
Answered
by
Matt-Deacalion
JeffBeltran
asked this question in
Q&A
-
is it possible to reference a variable from a In my case im trying to set up my proxy to rely on the value provided from the
|
Beta Was this translation helpful? Give feedback.
Answered by
Matt-Deacalion
Feb 26, 2021
Replies: 1 comment 8 replies
-
You could load the app level env variables and add them to the Node level env variables (credit: Alec Larson): import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
// import.meta.env.YinYang -> process.env.YinYang
return defineConfig({
plugins: [vue()],
});
} |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
JeffBeltran
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could load the app level env variables and add them to the Node level env variables (credit: Alec Larson):