purgecss icon indicating copy to clipboard operation
purgecss copied to clipboard

Tailwind v3 extractor

Open frederikhors opened this issue 2 years ago • 8 comments

Is your feature request related to a problem? Please describe. Now that Tailwind 3 is really close I think we should update Docs for a custom Tailwind extractor that works.

Describe the solution you'd like With Tailwind 2 we could have used a default extractor that they made available in an internal file, but it was not a public API and in fact it is gone now: https://github.com/tailwindlabs/tailwindcss/discussions/6162.

What to do with Tailwind 3?

Using extractor copied from Tailwind internals changes code from this:

*,
:after,
:before {
	border: 0 solid;
	box-sizing: border-box;
}
:after,
:before {
	--tw-content: "";
}

to this

* {
	border: 0 solid;
	box-sizing: border-box;
}

which is totally wrong (especially for Tailwind 3).

image

frederikhors avatar Nov 21 '21 16:11 frederikhors

This might be related to https://github.com/FullHuman/purgecss/issues/653

Ffloriel avatar Nov 28 '21 23:11 Ffloriel

I've also noticed that the default extractor doesn't work for Tailwind's "arbitrary values" syntax.

e.g. if I have text-[10px], it ends up getting stripped.

(For what it's worth, defaultExtractor: (content) => content.match(/[\w-/:[\]]+(?<!:)/g) || [], did the trick for me for the arbitrary values issue.)

birtles avatar Dec 10 '21 08:12 birtles

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 11 '22 00:03 github-actions[bot]

Please no.

frederikhors avatar Mar 11 '22 09:03 frederikhors

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 10 '22 00:06 github-actions[bot]

Nope

frederikhors avatar Jun 10 '22 10:06 frederikhors

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 09 '22 00:09 github-actions[bot]

I would also like this feature :)

IHIutch avatar Sep 19 '22 15:09 IHIutch

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Dec 19 '22 00:12 github-actions[bot]