Vite + Tailwind JIT -> broken HMR
See original GitHub issueDescribe 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
:
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:
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See #4150. I was lucky, the 1st thing I tried to bring in triggered the issue.
I can’t reproduce this, hmr works fine when I use tailwind and vue together, @jods4 can you provide a small repro, thanks