penthouse icon indicating copy to clipboard operation
penthouse copied to clipboard

Support css @layer rules for Tailwind CSS v4

Open jessedobbelaere opened this issue 11 months ago • 3 comments

Tailwind CSS v4 was released, which heavily relies on modern Cascade Layers with the @layer property

  • Tailwind CSS v4 Designed for the modern web — built on cutting-edge CSS features like cascade layers
  • https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

Sample of a generated css file using Tailwind v4:

/*! tailwindcss v4.1.5 | MIT License | https://tailwindcss.com */
@layer properties {
...
}
@layer theme {
    :root, :host {
        .. all css vars go here
    }
}
@layer base {
...
}
@layer utilities {
    .text-sm {
        font-size: var(--text-sm);
        line-height: var(--tw-leading, var(--text-sm--line-height))
    }
}

This causes the Critical CSS for my Tailwind V4 site to be almost completely empty, because literally everything is wrapped inside the @layer property, which is not part of the safelist of penthouse, so it gets stripped out.

Given the popularity of Tailwind, could we get such fix merged in a reasonable timeframe? 🙏

jessedobbelaere avatar May 07 '25 00:05 jessedobbelaere

Would love to see this merged in

khalwat avatar May 07 '25 01:05 khalwat

It's possible we might need to fork the repo and apply the changes, or get some additional maintainers added.

khalwat avatar May 07 '25 02:05 khalwat

@khalwat @jessedobbelaere also willing to help maintaining/forking this if necessary.

michtio avatar May 07 '25 11:05 michtio