gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.73k stars 7.45k forks source link

Extract classes from JavaScript files for hugo_stats.json #11459

Open doompadee opened 1 year ago

doompadee commented 1 year ago

Currently hugo_stats.json only includes elements found in the project .html files. But it's not uncommon to use HTML classes in JavaScript files as well (via element.classList.add()) and it would be helpful if Hugo could extract these as well.

bep commented 12 months ago

@doompadee so I do agree that this would be nice, but extracting classes from JS is a harder nut to crack.

We could consider looking at how Tailwind has approached this in their recent 3.x version. I think they collect "string identifiers" and does not care about what they are, which I guess is good enough for the prime use case here.

doompadee commented 2 months ago

With the new tailwind support (https://github.com/gohugoio/hugo/commit/e1317dd32281dc5ce670e34165dc7780c8f5892b) this issue should be gone?

bep commented 2 months ago

@doompadee not really. With the "old" Tailwind support, you could configure a set of folders or files for which to extract identifiers. So, you could/can point to where your JS files lives (e.g. assets). This works great in mono repo setups, but not so much in more complex setups.