tailwindcss-named-groups icon indicating copy to clipboard operation
tailwindcss-named-groups copied to clipboard

Compatibility with `purge`

Open thec0keman opened this issue 4 years ago • 2 comments

When setting up tailwind'd purge feature, our named groups appear to be purged. Is it possible to configure named groups in the safelist?

thec0keman avatar Jun 04 '21 16:06 thec0keman

As of Tailwind 3.0 I was having some problems with JIT purging classes inconsistently for the named groups (especially when having nested groups - usually would take the parent and purge the child).

I used the following in my config:

const config = {
...
  safelist: [{
    pattern: /.*/,
    variants: [
      "group-hover",
      "group-focus"
    ]
  }],
...
};

Note - this is working because it's safelisting all group tags of hover and focus across all the variants (so it may not be the smallest bundle you can get to -- you may want to narrow down the pattern a bit), but it works for my use-case.

m-rgba avatar Feb 18 '22 15:02 m-rgba

Extending on the above answer, my working code for tailwind 3.x in tailwind.config.js is:

...
module.exports = {
  content: [
    ...
  ],
  // safelisting so that namedGroups can work in tailwind 3.x
  safelist: [{
    pattern: /.*/,
    variants: [
      "group-hover",
      "group-focus"
    ]
  }],
...

Thanks @m-rgba

armorasha avatar Mar 23 '22 02:03 armorasha