Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove unused CSS classes from frameworks like bootstrap in a react project

We are currently developing a react project using webpack and babel and would like to have automatically removed unused CSS classes in the CSS frameworks Bootstrap and AdminLTE 2 which we use.

In the project we use webpack (v4.41.0), babel (v7.6.2) and react (16.10.1). To use CSS classes we are using the babel plugin babel-plugin-react-css-modules which uses css modules.

What is a modern and contemporary way to do this?

like image 242
A. Fendt Avatar asked Oct 26 '25 03:10

A. Fendt


1 Answers

As djfdev already wrote purgecss works quite well: purgcss simply searches all JavaScript files for occurrences of the CSS class strings of the used CSS files and removes those which cannot be found.

like image 113
A. Fendt Avatar answered Oct 28 '25 19:10

A. Fendt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!