spatie/laravel-mix-purgecss

PurgeCSS inline whitelist comments not working

Closed this issue · 3 comments

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!

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

I'm glad it helped you @mattstein!

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.