I'm using NuxtJS (VueJS) with TailwindCSS and PurgeCSS.
Until now, I was specifying complete CSS classes for colors like text-green-800
, bg-red-400
, etc. But when creating component it's not ideal while the color can be passed as a Prop, but it's also not possible to directly do bg-{color}-400
while PurgeCSS while remove the background colors not found.
So, I wanted to put those classes in the whitelistPatterns from PurgeCSS, allowing regex to protect some classes. This is what I've set up :
purgeCSS: {
whitelistPatterns: [/^bg-/, /^text-/, /^border-/]
},
But PurgeCSS is completely ignoring the configuration. I've tried many regex : /bg-/
, /bg/
, /^bg-.*/
, etc. None have worked.
I thought that maybe it's using the new version of PurgeCSS which uses safelist
instead, but when I set the whitelistPatterns like this :
purgeCSS: {
whitelistPatterns: ['text-green-800', /^bg-/, /^text-/, /^border-/]
},
Then the text-green-800
class is successfully protected. So i'm completely lost, nothing seems to work. And obviously only happening on production, so difficult to debug.
I've already found this post which gives exactly what I've done : PurgeCSS whitelist patterns with TailwindCSS
If anyone has a lead... Thank you!