Skip to content

PurgeCSS reference config omits component attribute selectors (over-purge under v3.6+) #2061

Description

@markdumay

Summary

With the built-in CSS purge enabled by default (v3.6+), rules written as attribute selectors are silently stripped from production CSS, because hugo_stats.json only records tag/class/id names — never attributes — and the reference config/postcss.config.js dynamicAttributes list does not include the attribute selectors that Hinode's own components use.

Examples (Hinode-owned)

  • components/_command.scss[data-prompt], [data-continuation-prompt]
  • (theme forks that add attribute-selector hooks hit the same class of problem, e.g. [data-js-cloak], .app-shell-content [data-body-col])

These render fine until purge activates, then their rules disappear in production only.

Why it bites consumers

Downstream sites build their own dynamicAttributes by enumerating their own SCSS, so they naturally miss the selectors owned by Hinode + its modules. The failure is invisible to a targeted grep of "expected" classes; it only shows in an exhaustive diff of [data-|aria|role] attribute selectors present in the unpurged vs. purged CSS.

Suggested fix

Add Hinode's own component attribute selectors to the reference dynamicAttributes (so consumers seeding from the reference inherit the protection), and/or document that consumers must enumerate attribute selectors from the compiled CSS rather than from templates. For compound selectors like .app-shell-content [data-body-col], the companion class must also be safelisted.

Found during an ecosystem-wide Hinode v3.7 upgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions