fix: copy .env file to build directory #3186
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
The migration from Vercel to Homebrew of an account that uses
NEXT_PUBLIC_*env vars failed as the builds in homebrew weren't inlining these env vars as expected.How it works?
This PR adds a step during build to copy the
.envfrom the source to the temporary.faststoredirectory, so that Nextjs can properly read theNEXT_PUBLIC_*env vars during build.How to test it?
NEXT_PUBLICenv var in the store code:console.log('NEXT_PUBLIC_TEST_VALUE', process.env.NEXT_PUBLIC_TEST_VALUE)NEXT_PUBLIC_TEST_VALUE=testyarn buildWithout this change, searching the built code for the variable, you can see the value was not inlined
With this change, you can see the value was inlined as expected
Starters Deploy Preview
References
Migration preventive incident (#inc-4855): https://vtex.enterprise.slack.com/archives/C0AB4N24R7A
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.