Is it possible to use part of hugo_stats.json directly in Hugo (for workaround a purgecss bug)


  • I encountered a problem using PurgeCCS when my css has some pattern selector like [class^="tf-"], [class*=" tf-"] .
    They where removed.
  • After debugging a lot, it is a bug upstream in PurgeCSS. See this issue.
  • Using regular expressions in whitelistPatterns do not work (see this issue), and as a workaround someone suggested to add the style list instead of the pattern selector.

As there can be a lot of (and changing/adding/removing) styles really used, and as Hugo already does this job by producing hugo_stats.json I was wondering if I could reuse this in the Hugo process.

I doubt it because this file is produced at the end of the Hugo build process.

I understand that I can post process this file and then reinject a part in my css, but I would avoid to break the beautiful Hugo worlflow by adding this hack.

Any idea, or solution waiting for (and if) upstream correcting this problem ??

I’m not sure what you mean by all of this.

Have you seen

Any reason why you cannot use a similar setup?

Bep, in fact I use your module as a base for all the PostCSS stuff … It works perfectly.

Problem is a bug in PurgeCSS ( &

It removes the pattern in CSS and regexp doesn’t works in whitelist.
Only workaround at the moment is to write the real classes one by one and not use a pattern.

I can do it by hand when I change/add some class, but was looking for guidance to make it part of the worklow.