Tailwind v4 isn't purging CSS

I’ve set up Tailwind v4 per the Hugo docs, and it’s working to create the necessary CSS. But it doesn’t seem to be purging unused CSS. At least I don’t think so because I see a lot of CSS generated and many, many rules that I’m not using.

I’ve added @import: bootstrap-icons.css and those unused styles are not being purged either.

Do I need to add optimize true to my css.TailwindCSS $opts?

Why not … try it?

I don’t know the details of what optimize does, but

  • The Hugo docs site uses minify: true (except when development) which is supposed to do both.
  • That produces a 13KB CSS file which is in the ball park of “good enough”, so I haven’t investigated further.
  • I have read that it’s on some level “less aggressive” than the old PurgeCSS setup, but also, I’m guessing, much faster and less painful.