-
Notifications
You must be signed in to change notification settings - Fork 580
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
[Help] How to use env var like import.meta.env.VITE_KEY
in main/preload ?
#209
Comments
BTW, currently I use |
It's probable a conservative desing, not sure if it's right. const conf: InlineConfig = {
// 🚧 Avoid recursive build caused by load config file
configFile: false,
envFile: false, // 👈👈👈👈👈👈👈
publicDir: false,
build: {
emptyOutDir: false,
minify: process.env./* from mode option */NODE_ENV === 'production',
},
} Perhaps, this feature is avaiable in |
Thank you for replying! |
Honestly, I thought the env file was exposed everywhere 😅 I was thinking that we don't need @caoxiemeihao So I want to say that yes, it's better to enable the |
Describe the problem you confuse
Vite supports env vars prefixed with "VITE_" if they are placed in the file
.env
.However in
electron-vite-vue
template, env vars likeimport.meta.env.VITE_KEY
can only be used in renderer process.How to reproduce:
npm create electron-vite
&npm i
.env
file at app root with the content:electron/electron-env.d.ts
:electron/main/index.ts
:electron/preload/index.ts
:src/main.ts
:npm run dev
The text was updated successfully, but these errors were encountered: