George Milev
George Milev

Reputation: 103

PurgeCSS with React-bootstrap possible?

I have a gatsby site with react-bootstrap, bootstrap and scss setup and I am trying to clear my unused css. For this I need to use purgeCss, but It doesn't work as it's needed. It seems it can't catch the classes in react-bootstrap components I am using in my pages. I read the documentation, try some fixes, but nothing worked. Can someone help me ?

Upvotes: 9

Views: 1819

Answers (1)

borracciaBlu
borracciaBlu

Reputation: 4225

To setup PurgeCSS to allow react-bootstrap classes i've used:

purgeCss: {
    whitelist: () => ['html', 'body', 'collapse', 'collapsing'],
    whitelistPatterns: () => [/modal*/, /accordion*/, /card*/],
    whitelistPatternsChildren: () => [/modal*/, /accordion*/, /card*/]
},

Upvotes: 6

Related Questions