Skip to content

Conversation

Norlock
Copy link

@Norlock Norlock commented Aug 17, 2025

The code to check if it contains modern tailwind variant is a bit brittle. My prettier overwrites the double quotes in CSS files with single quotes, and after that it won't detect it no more. Then no bundle is generated, I have now made it a litte bit less strict so it can contain both " and ', and also will not break if an extra space is added or not.

I have changed a bit of code so that the add function only creates the import and the bundler will do the installation. The code is a bit convoluted if I may say so, so maybe something else broke again, or not work as expected. The old code also read the css file twice, which is not very efficient.

In the components code I didn't find anything related to the flag detect_tailwind so maybe that is an existing bug (or works as expected).

Wouldn't a better name for that flag maybe be bundle_tailwind? Because that is what you either want or not want to do.

Fixes #113

@yoshi-monster
Copy link
Contributor

Hi!

this is very interesting! Thank you so much for figuring out what went wrong here 💜

I think these changes are a bit too broad and should be discussed first, though; right now, the main feature and reason for the add command is to download the binary. This makes it behave similarly to the add esbuild command, and is really useful on CI where you want to handle the outcome of downloading the binary and actually compiling your app differently for example. It also plays nicely with the proposed --use-system-* flag.

I think your parser could also be improved! string.to_graphemes is unfortunately one of the most expensive things you can do, so it would be great if it got away with just pattern matching and using functions like split_once and trim. I think it should match the regular expression @import\s*['"]tailwindcss.

Thank you for looking into this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error logs of tailwind not shown
2 participants