-
Notifications
You must be signed in to change notification settings - Fork 389
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
Feature/custom regex #190
base: master
Are you sure you want to change the base?
Feature/custom regex #190
Conversation
Please please merge this. 🙏 🙂 |
Good PR. However I feel like limiting the regex to always be inside [] is not a good idea. Would it be possible to change it so that you're able to define any regex? Or change the description of the "regex" option. |
Generalized regex or not, we need this. 👍 |
I had to dive into the code again, since it has been a while. To following choices I've made for this implementation: In the original code you use 2 different kinds of regex. Those are: The solutions I choose support of regex does fit in both kinds of regex. I think it's an obstacle to let the user define both full regex since the regex need each other. It is easier to only define the inner part of the regex: Their for since this solution is probably already solving the problems we know off I think this solution is fine for now. I will change the description of what the regex attribute does. If we think a full regex solution is needed in the future we could adjust the script by that time, since full regex support is more complicated to build in. |
I ran into a problem where not enough classes from the Foundation FrameWork were filtered. So i decided to make some adjustments to the purifying plugin.
I also found an outdated pull request to stricter purifying (#139 ). I figured out that it would be usefull if people could write their own regex to fit their own needs.
This features add the option to modify the regex expression to purify the css. For me this saved up to **~ 33.6%** instead of only **~ 8.7%**. This makes big sense to me.
You can use it option by adding the option
regex
to your config file. By default the regex splits words on everything which is nota-z
. By adjusting the regex toa-z_-
it doesn't split whole classes in half any longer.Use for example:
So instead of accepting
.block-padding
and.block-padding-vertical
when only.block-padding
is used. It now filters.block-padding-vertical
since this one is not used.This also means that you can filter a lot of unused Foundation Framework classes like:
I hope you find this usefull and accept my request.