@apply causes vitejs to HMR all files until maximum call stack error.
See original GitHub issueWhat version of Tailwind CSS are you using?
3.0.23
What build tool (or framework if it abstracts the build tool) are you using?
Vite 2.8.6
What version of Node.js are you using?
v17.5.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
Describe your issue
When using tailwindcss + vite, if you use css modules with @apply, when you save any file, it will cause an infinite HMR loop. I’m reporting this here cause this only happens while using tailwind’s apply directive.
TailwindCSS config
module.exports = {
content: ["index.html", "src/**/*.tsx"],
theme: {
extend: {
screens: {
standalone: { raw: "(display-mode: standalone)" },
},
},
},
plugins: [require("@tailwindcss/forms")],
};
PostCSS config
module.exports = {
plugins: [
require("tailwindcss/nesting")(require("postcss-nesting")),
require("tailwindcss"),
require("autoprefixer"),
],
};
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Need to save a file twice before Vite HMR and vitejs/plugin ...
I am setting up a boilerplate using React and Vite to build the frontend of my Electron application, the boilerplate is almost done...
Read more >Troubleshooting - Vite
If you are using Linux, file descriptor limits and inotify limits may be causing the issue. As Vite does not bundle most of...
Read more >vitest cannot access before initialization - You.com - You.com
error showing: referenceerror: cannot access 'user' before initialization , I encored the password, after I called use, or there is an error will...
Read more >Blog - Next.js 13
The app directory is currently in beta and we do not recommend using it in production yet. You can use Next.js 13 with...
Read more >Understanding a Comparison: Webpack vs ViteJS - Radixweb
Stiil confused about how does Vite work? Let's compare how Vite works to the standard webpack config using webpack-dev-server, which all ...
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
So I’m not able to reproduce the maximum call stack error but I do see the list of files being much longer than necessary.
I believe this is because in v3.0.23 every file with
@apply
is registered as changing the “context” that Tailwind CSS uses to build CSS which has the effect of registering more files for updates than necessary. I’m about 95% sure this was fixed by https://github.com/tailwindlabs/tailwindcss/pull/7524 but it’s not in a tagged release yet.In the meantime you can use our insiders build by running
npm install tailwindcss@insiders
and it should resolve your problem. Can you give that a try and let us know if that fixes it for you?Hahah YES. Glad to hear that fixes it for you! 🎉🎉 Happy to help!
Closing since the issue itself is fixed. I don’t know when we’ll have a tagged release out next but the insiders build is sufficient to use for now. 🚀