Tailwind 2.0 poor performance as part of a webpack PostCSS build system
Problem
Description of the problem Tailwind CSS 2.0 builds slowly as part of a HMR webpack build system. It is slower than the release, but that could just be due to the amount of CSS generated increasing. I filed a very similar issue a month ago https://github.com/tailwindlabs/tailwindcss/issues/2544 and worked around the problem by splitting the CSS up into separate chunks. Global `@apply` still worked, and everything was great. It's all written up in the article Speeding Up Tailwind CSS Builds However with Tailwind CSS 2.0, the technique described in the article breaks. Desired solution I'm hoping to have the DX of working with Tailwind CSS 2.0 be improved from a HMR build time perspective. I realize that you can only optimize your generation of CSS so much, and a PR is in the works to do just that with `esbuild`. I also realize that part of the slowness here is simply webpack and the surrounding ecosystem being slow when dealing with massive amounts of CSS (though I've optimized that quite a bit here). However, the paradigm that Tailwind CSS is using is what generates a massive amount of CSS, and webpack is a very widely used tool that many things are built upon. Some way to address the DX here would be great; huge gains can be made using the CSS splitting technique described in the article, maybe there could be a way to restore that functionality to Tailwind 2.x? Link to a minimal reproduction: I made a new branch with Tailwind 2.0, webpack 5, PostCSS 8, and all the g
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Tailwind 2.0 poor performance as part of a webpack PostCSS build system
Ah yes, sorry, I pushed up a new branch that demonstrates the problem: https://github.com/nystudio107/tailwind-css-performance/tree/broken-tailwind-2.x So if I try to do this in global.pcss: [code block] I end up with this: [code block] The above works fine when using Tailwind 1.x, despite being broken up into separately imported files. I assumed this was a result of the various internal `@
Trust Score
3 verifications
- 1
Ah yes, sorry, I pushed up a new branch that demonstrates the problem: https://g
Ah yes, sorry, I pushed up a new branch that demonstrates the problem: https://github.com/nystudio107/tailwind-css-performance/tree/broken-tailwind-2.x
- 2
So if I try to do this in global.pcss:
So if I try to do this in global.pcss:
- 3
The above works fine when using Tailwind 1.x, despite being broken up into separ
The above works fine when using Tailwind 1.x, despite being broken up into separately imported files.
- 4
I assumed this was a result of the various internal `@apply` changes that were m
I assumed this was a result of the various internal `@apply` changes that were made.
Validation
Resolved in tailwindlabs/tailwindcss GitHub issue #2820. Community reactions: 3 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep