spatie / laravel-mix-purgecss

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

PurgeCSS inline whitelist comments not working #76

Closed hybridvision closed 4 years ago

hybridvision commented 5 years ago

Hello team Spatie! Thanks for creating this handy package :)

I just came across a problem that took me a while to figure out so I thought I'd share it here (and maybe there is something that can be done to make this smoother, even if it's just an extra note in the documentation).

A quick bit of background info: I was finding that some of the CSS I wrote to style 3rd party components (eg. MMenu) was being stripped out. Rather than trying to whitelist all the patterns, I saw in the PurgeCSS docs that you can whitelist CSS inline by adding special comments.

I tried adding /* purgecss start ignore */ and /* purgecss end ignore */ to my file but I found it wasn't working. Eventually I realised that these comments were being stripped before getting to PurgeCSS, so you have to add them like this instead (note the extra !):

/*! purgecss start ignore */

...

/*! purgecss end ignore */

These comments are left alone by Laravel Mix and then PurgeCSS removes them when it is done.

I don't know if there's anything that can be done to improve this but adjusting the ignore comments is a pretty simple fix. If only I'd known that an hour ago!

mattstein commented 5 years ago

Thank you for pointing this out, @hybridvision! Saved me an untold amount of head-scratching.

hybridvision commented 5 years ago

I'm glad it helped you @mattstein!

spatie-bot commented 4 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.