Skip to content
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

How to pass environment variables to build ? #3558

Closed
3 tasks done
alxpereira opened this issue Apr 3, 2024 · 5 comments
Closed
3 tasks done

How to pass environment variables to build ? #3558

alxpereira opened this issue Apr 3, 2024 · 5 comments

Comments

@alxpereira
Copy link

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.2.0

Electron version

v28.2.3

Operating system

macOS 14.2.1

Last known working Electron Forge version

No response

Expected behavior

I have an issue on using the make command and passing env variables.
As on a lot of projects, I'm setting all my env variables in a .env file at the root of the project.
When running the project using npm run start, no issue, everything works well (_VITE and also dotenv related variables are load)
But when trying to build the DMG using npm run make the variables are not loaded.

Actual behavior

The variables are not loaded in main / loader / renderer. (undefined)

Steps to reproduce

Run npm run make using a .env file and some variables in the the main or renderer.

Additional information

No response

@BigerXie
Copy link

BigerXie commented Apr 5, 2024

+1

@BigerXie
Copy link

BigerXie commented Apr 5, 2024

@alxpereira hi bro, do you have any solution to fix this problem?

@alxpereira
Copy link
Author

alxpereira commented Apr 6, 2024

@alxpereira hi bro, do you have any solution to fix this problem?

for the moment, nope.. I will in the end maybe pass the env file directly in the build process forcing dot-env to parse it directly in my files. But that won't be the final clean solution.

@BigerXie
Copy link

BigerXie commented Apr 6, 2024

@alxpereira Hi, my application bulit it with electron-forge & vite-typescript & vue, so I found this https://github.com/electron/forge/issues/3375 can sovle my problem, and BTW I pass NODE_ENV from npm command as environment variable. hope it can help you or give you some inspires. thanks your replay.

@VerteDinde
Copy link
Member

Thanks for reaching out and logging this issue! Because we treat our issues list as the team's backlog, we close issues that are questions since they don't represent a task needing to be completed. For most questions about Electron there are a lot of options.

Check out the Electron community. There are also a bunch of helpful people in this Discord that should be willing to point you in the right direction. For your question, I'd recommend the Discord - we have many active help channels and mentors, as well as fellow devs, who can help you out.

@VerteDinde VerteDinde closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants