tailwindlabs/tailwindcss

Tailwind Play and Play CDN don't work with some custom utilities

barvian opened this issue · 3 comments

What version of Tailwind CSS are you using?

Tailwind Play 3.4.3

Reproduction URL

https://play.tailwindcss.com/POsJX9j8ik
https://codepen.io/mbarvian/pen/mdYRLVw (Play CDN)

Describe your issue

It seems that Tailwind Play and Play CDN don't pick up every utility, specifically ones that would normally be enabled by custom extractors.

I think I see the issue on Play CDN. It looks like the script overrides config.content with a virtual file containing all the classes in the current page. Presumably, though, that still gets run through the default extractor. Would it be possible if Play CDN instead overrode config.content with something like this?

content: {
  files: [{ raw: '' }],
  extract: () => [/* array of all class names on the page */]
}

I think this would be more efficient as well.

I've updated both the CDN and Play so we take into account the class names directly. Additionally, in Play, we also run the default extractor on top of this so any existing Play doesn't break if the class was used outside of a class attribute. You'll want to use at least v3.4.4 on the CDN.

I'll note that we did not enable use of custom extractors in either location — but doing so should be unnecessary.

If you look both reproductions above now work! (and you can remove the custom extractor code from both) 👍

@thecrypticace Thank you!!