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 ?
1 Answer
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*/]
},
1 Comment
James Bond
But you just manually manage whitelist classes, it is not a solution.
Col xs={6}wouldn't work, because the purgeCSS cannot make any sense of it. As a workaround I decided to use plain HTML for grids and for other react-bootstrap components like buttons I just add the class explicitly like<Button className="btn-success"