简体   繁体   中英

PurgeCSS misses Tailwind classes that use a colon:

I have a website that uses tailwind. I'd like to keep the css size small, so I decided to use purgecss. I'm building the static site with python, so I'd like to use the CLI. Here's the code in my Makefile that handles this.

NODE_ENV=production npx purgecss --css css/*.css --content public/*.html public/**/*.html --output demo
npx uglifycss demo/*.css > public/style.css
rm -rf demo/*.css

Here's the thing though; it seems to make the css files smaller, but purgecss seems to completely skip any classes that have a colon (like sm:grid-cols-2 ). Take this html snippet:

<ul class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 pt-4">
   ...
</ul>

Here's what the site looks like.

在此处输入图像描述

Here's what the site should look like.

在此处输入图像描述

The grid switches to grid-cols-1 while the lg:grid-cols-4 class should be triggered. Looking at the public/style.css I can also confirm that the lg:grid-cols-4 class isn't listed.

Am I calling the purgecss -command wrong? It feels like I'm missing something.

Technically, this is a duplicate question. The solution can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM