question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite + Tailwind JIT -> broken HMR

See original GitHub issue

Describe the bug

When I add Tailwind (JIT mode) to my PostCSS config, HMR doesn’t kick-in for Vue templates anymore.

Reproduction

Without tailwindcss in my .postcssrc.json: kCHu4zilUb Notice the hmr update home.vue appearing in terminal (and it works in browser).

Now let’s add Tailwind to .postcssrc.json:

{
  "plugins": {
    "tailwindcss": {}
  }
}

Note that I’m using JIT mode, in tailwind.config.js:

module.exports = {
  mode: "jit",
  purge: ["./{Components,Modules}/**/*.vue", "./app.vue"],
}

Restart, it works. Let’s try hmr again: MWmzJ89hDo

As you can see, only index.css was HMR. This is semi-expected as Tailwind JIT watches template changes and dynamically create required styles (although I did not create any new style in this edit – but it could be the case). The home.vue template HMR is nowhere to be seen, though; it didn’t update in browser, of course.

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (12) x64 Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
    Memory: 6.30 GB / 15.79 GB
  Binaries:
    Node: 15.5.1 - C:\Program Files\nodejs\node.EXE
    npm: 7.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.18362.1593.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.4 => 1.2.4 
    vite: ^2.4.0 => 2.4.0 

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
jods4commented, Jul 6, 2021

See #4150. I was lucky, the 1st thing I tried to bring in triggered the issue.

1reaction
OneNailcommented, Jul 6, 2021

@OneNail would you take a look at this one?

I can’t reproduce this, hmr works fine when I use tailwind and vue together, @jods4 can you provide a small repro, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Patching Vite HMR To Work With Tailwind JIT - Mohammed A.
On my first attempt, I started googling if anyone has the same problem, I found a Github issue states that the HMR was...
Read more >
Install Tailwind CSS with Vite
Install tailwindcss and its peer dependencies via npm, and then run the init command to generate both tailwind.config.cjs and postcss.config.cjs . Terminal.
Read more >
Tailwind 3 isn't generating new classes when developing in ...
js . So it looks like the HMR problem was caused by having my PostCSS config options directly in svelte-preprocess in my svelte.config....
Read more >
Using Vite with Inertia — Laravel, Vue & Tailwind
For the sake of completeness, here is Tailwind config (JIT is amazing as well!) module.exports = { mode: "jit", purge: ['./resources/**/*.{js, ...
Read more >
Setting up a dev environment with React, Vite, and Tailwind
And with the performance improvements that come with the new JIT compiler, Tailwind CSS has become a clear developer's favorite. Vite also ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found