-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can @tailwindcss/vite scan step seems to miss classes in waku #16585
Comments
some nested components not working with the tailwind vite plugin. the hmr seemed broken when using the tailwind plugin as well. related issue: tailwindlabs/tailwindcss#16585
some nested components not working with the tailwind vite plugin. the hmr seemed broken when using the tailwind plugin as well. related issue: tailwindlabs/tailwindcss#16585 --------- Co-authored-by: Tyler <26290074+thegitduck@users.noreply.github.com> Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Thanks for the report @tylersayshi. Two quick questions:
I'm asking because the way the moudle-graph dependency scanner works has some drawbacks around production builds with SSR specifically, see this PR for some context and a proposed fix: #16425 Would love to understand if this approach would work for you! |
With this as the issue, we should be able to configure vite to use the tailwind plugin for both builds. We manage the vite configs for users, so we should move to including the tailwind plugin through our waku.config.ts to be sure it's always used if I am following correctly here. Thanks for linking #16425 btw! That looks like it will help us as well, we do run SSR with RSC. |
I think that alone won't help, the issue is still that one build emits the css file but another build transforms the components. Let me keep you posted here, we're testing some larger scale Vite changes that should resolve this as well now (basically turning on that new option from #16425 by default). |
Alternative to #16425 Fixes #16585 Fixes #16389 Fixes #16252 Fixes #15794 Fixes #16646 Fixes #16358 This PR changes the Vite plugin to use the file-system to discover potential class names instead of relying on the module-graph. This comes after a lot of testing and various issue reports where builds that span different Vite instances were missing class names. Because we now scan for candidates using the file-system, we can also remove a lot of the bookkeeping necessary to make production builds and development builds work as we no longer have to change the resulting stylesheet based on the `transform` callbacks of other files that might happen later. This change comes at a small performance penalty that is noticeable especially on very large projects with many files to scan. However, we offset that change by fixing an issue that I found in the current Vite integration that did a needless rebuild of the whole Tailwind root whenever any source file changed. Because of how impactful this change is, I expect many normal to medium sized projects to actually see a performance improvement after these changes. Furthermore we do plan to continue to use the module-graph to further improve the performance in dev mode. ## Test plan - Added new integration tests with cases found across the issues above. - Manual testing by adding a local version of the Vite plugin to repos from the issue list above and the [tailwindcss playgrounds](https://github.com/philipp-spiess/tailwindcss-playgrounds).
@tylersayshi Hey! We decided to land some changes in the Vite plugin that will ensure that both SSR and RSC builds now have access to the same class name list. We plan to release this in a patch very soon (hopefully today!). Thanks for the bug report. 🙇 |
Thank you! |
We're seeing not all classes be picked up by the tailwind vite plugin right now. I've attached a reproduction (thanks to one of our waku users on discord). The issue in this case is that bg-blue-400 does not make it into the tailwind style output. I am able to see the className in the html output so it does seem like a bug with the plugin for now to me.
repro: https://github.com/tylersayshi/waku-vite-tailwind-bug
From this code it seems like this should auto-read from the html output, but it does seem to miss this case for now.
https://github.com/tailwindlabs/tailwindcss/blob/main/packages/%40tailwindcss-vite/src/index.ts#L187-L214
I'm happy to help however I can here :)
Update: I pushed a working example with postcss here: https://github.com/tylersayshi/waku-vite-tailwind-bug/tree/postcss
The text was updated successfully, but these errors were encountered: