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

fix: monkey-patch Vite HMR issue & make it reproducible (#464) #496

Merged
merged 3 commits into from
Jul 11, 2022
Merged

fix: monkey-patch Vite HMR issue & make it reproducible (#464) #496

merged 3 commits into from
Jul 11, 2022

Conversation

makkarpov
Copy link
Contributor

Surely, I understand that this is not the best way to fix HMR, and original problem probably lies closer to Vite itself. But this at least makes tailwind usable when Vite breaks, without waiting for upstream fixes.

You can run the playground and edit some styles there, which will result in following HMR events:

HMR events

event 1 (emitted by fix):

{
   "type":"update",
   "updates":[
      {
         "type":"js-update",
         "path":"/@fs/xxx/nuxt-tailwindcss/src/runtime/tailwind.css",
         "acceptedPath":"/@fs/xxx/nuxt-tailwindcss/src/runtime/tailwind.css",
         "timestamp":1657368983171
      },
      {
         "type":"css-update",
         "path":"/@fs/xxx/nuxt-tailwindcss/src/runtime/tailwind.css?direct",
         "acceptedPath":"/@fs/xxx/nuxt-tailwindcss/src/runtime/tailwind.css?direct",
         "timestamp":1657368983171
      }
   ]
}

event 2 (emitted by Vite):

{
   "type":"update",
   "updates":[
      {
         "type":"js-update",
         "timestamp":1657368983171,
         "path":"/pages/index.vue?macro=true",
         "acceptedPath":"/pages/index.vue?macro=true"
      }
   ]
}

Vite event is completely missing any style reload, and disabling the fix will indeed break HMR. Also, config options is provided to switch the fix off if it will break anything some time.

(i'm also not sure what to do with huge yarn.lock diff consisting primarily of shuffled lines)

@atinux atinux merged commit 8cc1cfa into nuxt-modules:main Jul 11, 2022
@atinux
Copy link
Collaborator

atinux commented Jul 11, 2022

Thank you ❤️

@Tahul Tahul mentioned this pull request Jul 12, 2022
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