Skip to content
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

Feature/vite scripts dev mode #76

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Conversation

ThaNarie
Copy link
Member

Use dev mode by default when NODE_ENV var is not set

Otherwise locally you would use production mode when running npm run dev, which is unexpected.

After fixing that, I ran into another issue:

vite-scripts: Change injection point of entry path in HTML

The default setting, depending on the order of how plugins are
configured, would result in the HMR plugin code being injected AFTER the
entry script. This would mean that component code would execute before
HMR code was set up, and would fail.

Potentially there are 3 options to fix this;

  1. change enforce: 'pre' to post to allow executing after other plugins
  2. change the order of plugins in scripts/react-vite/config to append the react-vite plugin before the super plugins, but that could have other side-effects in the future.
  3. change the injectTo from prepend-head to head to make sure it's always injected into other

Here the 3rd option is chosen.

The default setting, depending on the order of how plugins are
configured, would result in the HMR plugin code being injected AFTER the
entry script. This would mean that component code would execute before
HMR code was set up, and would fail.

Potentially there are 3 options to fix this;
1) change `enforce: 'pre'` to `post` to allow executing after other
   plugins
2) change the order of plugins in `scripts/react-vite/config` to append
   the `react-vite` plugin before the super plugins, but that could have
   other side-effects in the future.
3) change the `injectTo` from `prepend-head` to `head` to make sure it's
   always injected into other

Here the 3rd option is chosen.
@ThaNarie ThaNarie merged commit cedc5d7 into main Aug 24, 2022
@ThaNarie ThaNarie deleted the feature/vite-scripts-dev-mode branch August 24, 2022 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants