-
Notifications
You must be signed in to change notification settings - Fork 23
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
It causes an issue during the build time of production. #10
Comments
In the README this library explains how it was originally built for Docker/VM environments where environment variables are set in the runtime environments from which they are built, and therefore they purposely pull env values ONLY from In non-dev builds, it still reads from the specified .env file, however, it only reads the keys to know which That's some background as to why it's working the way it's working, however I have a solution to fix your exact problem, because I had this problem too:
env-cmd -f .env.prod runtime-env-cra --config-name ./build-prod/runtime-env.js --env-file .env.prod This is the exact command I use for an enterprise app with a static compile, build-once-for-all-environments-ahead-of-time build process. I then statically serve my React app. It's as simple as it looks: So YES this library can be used to generate map .env file variables to your statically served React app as long as you run generate it at build time (which is a necessary condition for it being a statically served app anyways). @kHRISl33t thoughts on this approach, and possible adding some example usage of |
Thanks for the question @hafizadil123! Can you share a basic example with me when the problem occurs and also how you are doing your production build? The idea behind the package is when you are developing locally, you always want to use the values from your e.g: .env.development NODE_ENV=development
API_URL=https://my-api-url.dev.com So if you are starting your app locally with On production you can use your You can use the same file if you want. If you don't have different environment variables between environments. To parse the variables from the file instead of the system, just pass in e.g: But if you can share the CI/CD flow or the way you are deploying, I could help more :) |
Sure, we can add some examples :) never used |
Closing this because of it's inactivity. |
During the creation of build for production environment, package do not allow us to read the variables from the .env files as there is a condition inside the code to get it from pocess.env if env is not development. can you guid if you still handle this case or I can raise PR for this?
Thanks
The text was updated successfully, but these errors were encountered: