spatie / laravel-mix-purgecss

Zero-config Purgecss for Laravel Mix
https://spatie.be/en/opensource
MIT License
874 stars 38 forks source link

Purge CSS is incorrectly removing classes containing the special character "!" (important) #69

Closed ghost closed 5 years ago

ghost commented 5 years ago

If I define a class with the special character ! in the name, purge css will always remove this class. For example, if I define my css class as:

.\!red-text {
  color: #ff0000 !important;
}

And then my html looks like:

<div class="!red-text">Bla bla bla</div>

Then the !red-text class will be purged, even though this class is actively being used.

Note: I haven't tested any other special characters, but I assume they are working correctly because I am using tailwindcss and haven't noticed any other issues (Tailwind uses the special : character extensively in class names).

riasvdv commented 5 years ago

This is probably an issue with the regex pattern which is not accounting for the exclamation character. You can change this by using the extractorPattern option https://github.com/spatie/laravel-mix-purgecss#usage