New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Css attribute selectors [Request] #30
Comments
This is a webpack setup, but the configuration options are the same.
This will match all selectors and classes that has |
The @Ffloriel, is there a way to match for the entire thing? E.g. More InfoAlso, if I have these 2 classes:
and I am calling
Only I have tried the following configurations and all failed:
Some help would be appreciated :) EDITThe following works, but man it took me abit of time to figure it out.
|
I see, I think what you need is to define a custom extractor. Check this gist for using purgecss with tailwindcss |
According to my tests and from what I found out, a custom extractor is for custom extraction of the glob files, not the CSS files. Let me know if I'm wrong. |
By default, selectors like |
Correct me if I'm wrong. Are you saying that the custom extractor will extract strings from both the css and the html files? |
No. Extractors are used to extract selectors from content files (html, pug, ...) w-6\/12 {
color: green;
}
md\:w-3\/12 {
color: blue;
} and an html file: <div class="flexgrid">
<div class="w-6/12 md:w-3/12">Content<div>
<div class="w-6/12 md:w-3/12">Content<div>
<div> First, purgecss will use an extractor to determine which selectors are used. The default extractor will considered |
Thanks for explaining and trying to help. However I still couldn't get the extractor to work. I still can't get it to work properly. LOL What I am trying to do here is to get PurgeCSS to read not allow both of the following classes to pass:
Because the usage of this is just simply using the
So with this html, the extractor will only pick up the flexgrid class. And after comparing it with the css file above, only So the question is how do I get PurgeCSS to support custom css selectors such as the css example above? |
Thanks for the clarification. I understand the problem now. |
The issue should be fix in v0.14.0. Let me know if you found any issues with it. |
Will this only work under What do you think? |
It should work for both. |
Hmm, tested it and somehow it didn't work unless
Output
The test in the test folder had |
There are tests for both with and without |
Hey @Ffloriel. Here's the repo. I hope I did it correctly, I used gulp instead of webpack. |
@pxwee5 thank you very much. |
gulp-purgecss was still using the v0.13.0. gulp-purgecss version is now aligned with purgecss. .flexgrid {
background-color: black
}
.flexgrid[class*=w] {
background-color: blue;
}
.flexgrid>*[class*=w-] {
background-color: yellow;
} |
Gah. That was it! Didn't know I have to upgrade the bundler plugins as well. |
I can't seem to find a way to get purgecss to work with css selectors like [class*="section-"] or [title~="flower"].
Is there a method I'm overlooking or if not, is there a way to implement this?
The text was updated successfully, but these errors were encountered: