-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Introduce env to next.config.js for build-time configuration #6212
Conversation
LGTM - question though: I know convention indicates defines should be |
How about if the key is prefixed with https://github.com/zeit/next.js/pull/6212/files#diff-5bfca4ba8d55b02e7cf3885c1f5439d8R1561 |
@developit I don't think we should introduce the option for users to add global variables like that, especially with type checking / linting that can become an issue. Next.js provides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for this in test/integration/config
I have some observations about this approach.
So, what is then really advantage of having |
@marcinczenko In the last point, i think it should just work with Having the |
Thanks @revskill10. I will check |
@revskill10 confirmed. |
I may be missing something here, but it appears that the config key reference is only for build time env variables? Are there no solutions for run time variables with serverless? |
I was able to fix this by tunneling the process.env. down through getInitialProps to the client. |
Build time configuration
The way build-time configuration works is by inlining the provided values into the Javascript bundle.
You can add the
env
key innext.config.js
:This will allow you to use
process.env.customKey
in your code. For example:Also adds an error when
publicRuntimeConfig
/serverRuntimeConfig
is used in combination withtarget: 'serverless'