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
fix(plugin-react): jsxDev is not a function when is set NODE_ENV in env files #10861
Conversation
@Dunqing would it be possible to modify the react playground to test this so we avoid a regression later? |
Sure! |
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.
Thanks @Dunqing! This does indeed fix my issue. I made one small suggestion to hopefully help future travelers, but this is great.
packages/plugin-react/src/index.ts
Outdated
@@ -118,8 +119,16 @@ export default function viteReact(opts: Options = {}): PluginOption[] { | |||
const viteBabel: Plugin = { | |||
name: 'vite:react-babel', | |||
enforce: 'pre', | |||
config(_, { mode }) { | |||
config(userConfig, { mode }) { | |||
// Copied from https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L488-L490 |
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.
This comment range could be expanded, since we're now copying more of that logic.
Maybe something like: https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L477-L494
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.
Thank you for your review!
Description
fix: #10854
We need to execute loadEnv, because
process.env.VITE_USER_NODE_ENV
is only defined in it.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).