tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

[v4] Issue with vite-plugin-vue-devtools and v4 beta.1

Open HummingMind opened this issue 1 year ago • 8 comments

What version of Tailwind CSS are you using?

4.0.0-beta.1

What build tool (or framework if it abstracts the build tool) are you using?

Vite 5.4.11

What version of Node.js are you using?

v22.11.0

What browser are you using?

Chrome 131.0.6778.86

What operating system are you using?

Windows 11 24H2

Reproduction URL

StackBlitz Can't run it there though. They don't seem to allow plugins like tailwindcss in vite.config.js

image

Another way to reproduce is just to npm create vue@latest with vue router and just add TailwindCSS v4 alpha/beta to it and run the dev server.

Describe your issue

When using vue and vue-router, during vite HMR, the vite-plugin-vue-devtools, version 7.6.4, freaks out with this error:

image

and the page looks like this:

image

HummingMind avatar Nov 20 '24 23:11 HummingMind

@HummingMind Hey there! I wasn't able to reproduce this locally using the latest main version of Tailwind CSS (but I don't think we made any Vite changes there before the last release 🤔).

Here's the example I tried: https://github.com/philipp-spiess/tailwindcss-playgrounds/tree/main/vue

It's just a npm create vue@latest like you said with Tailwind CSS v4 installed as a Vite extension and the dev server works just fine (tried to make changes in the .vue and .css files).

philipp-spiess avatar Nov 21 '24 10:11 philipp-spiess

@philipp-spiess

I did not give out the full information in the origianl post. It's not just a vue@latest with TW4 and Vue Router. But it's also with unplugin-vue-router, which automatically generates the routes, based on file-based routing, instead of manually configuring them.

I was able to reproduce locally, in a clean create-vue project. I'll use that as the new re-production.

HummingMind avatar Nov 22 '24 00:11 HummingMind

@philipp-spiess Ok, the new reproduction is up. The same link in the original post. I was able to download it and reproduce the problem.

When you run the "dev" script, just go into the /pages/index.vue and just add some tailwind classes to the paragraph element to trigger HMR.

Here is what I see in the client console:

image

HummingMind avatar Nov 22 '24 00:11 HummingMind

Just noticed that in this error: image

the path start with /ue-devtools-path and I would think it should be /vue-devtools-path seems like something might be removing the v letter 🤣

If I remove tailwind, when I make css updates, I only see this: image

So tailwind seems to be triggering different hot updates.

HummingMind avatar Nov 23 '24 03:11 HummingMind

Just tested by switching from the @tailwindcss/vite to the @tailwindcss/postcss and this issue does not happen with the PostCSS plugin.

So it has something to do with the new tailwindcss vite plugin.

Thank you!

HummingMind avatar Nov 23 '24 23:11 HummingMind

Here is what I see in the devtools with the PostCSS plugin, where everything works:

image

HummingMind avatar Nov 23 '24 23:11 HummingMind

Oh I wonder if this is the same issue as https://github.com/tailwindlabs/tailwindcss/issues/15159 and has to do with virtual modules not being resolved correctly.

Thanks for putting together the repro!

philipp-spiess avatar Nov 25 '24 10:11 philipp-spiess

Still happens with beta.3 🍻

HummingMind avatar Nov 27 '24 21:11 HummingMind

Still happens with beta.3 🍻 @HummingMind I haven't the problem anymore on beta.6

ronarthas avatar Dec 13 '24 09:12 ronarthas

It's much better on beta.6. You can still see "the jump" on the very first window load (once the browser opens), but HMR works fine after that point, where it did not with beta.3. So this could probably be cosnidered "fixed", if there is no way to improve the initial page load.

Thank you for all the hard work!

HummingMind avatar Dec 13 '24 16:12 HummingMind

The "jump" seems to be Vite dev server itself, not related to TailwindCSS. So, I'll go ahead and clsoe this, as it seems to work fine with beta.6.

HummingMind avatar Dec 26 '24 21:12 HummingMind