purgecss: Can't handle attribute pattern selector

purgecss doesn’t understand attribute pattern selector like this one from bootstrap 4:

.form-row > [class*="col-"]

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 14
  • Comments: 18 (6 by maintainers)

Most upvoted comments

@evromalarkey ah I see, it’s this issue then: https://github.com/FullHuman/purgecss/issues/392. I’ll look into it.

@shhlkien Thanks a lot for the repro repository! Attributes are treated separately between name and value.
You would need to safelist the name of the attribute: class and the value: icon-

Which in your example will be:

safelist: ['icon', 'class', ' icon-'],

Is there an ETA on the fix for this? I am running into this issue when there is a space: [class*=" col"]

v4.0.2 contains a fix to handle attribute selectors with spaces. Let me know if you are experiencing any issues.