feat: add option to exclude global define and env replacement #5577
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.
Description
Intent to fix vuejs/vitepress#419, but not completely resolved.
vite will automatically escape and replace the string form"process.env.NODE_ENV:" content!!! #3077
Library Mode replaces "process.env.NODE_ENV" #3229
Handling server-side/sensitive/runtime variables #3176
Ideally, the replacement of define and env can be turned off by specifying options, as in my test example.
I put forward this PR to stimulate discussion about whether the problems caused by string replacement should be fixed.
This is just one of my attempts, there should be other better ways to welcome you to point it out.
Thank you for your positive opinions.
Additional context
When I wrote the test example, I also found the error of define and pre-building, see also: #5570
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).