You can see an example here.

Created with create-react-app

This example shows how to set up Purgecss with create-react-app template. Once you initialized your project with npx create-react-app app, install the webpack plugin for purgecss:

npm i --save-dev glob-all purgecss-webpack-plugin

eject create-react-app

You need to eject in order to expose the webpack configuration offered by original create-react-app

Now, modify the file config/ by adding the following code with the rest of the imports:

// import Purgecss webpack plugin and glob-all
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')

...and directly before new ManifestPlugin(...) in the plugins list, add this:

// Remove unused css with Purgecss. See
// for more information about purgecss.
// Specify the path of the html files and source files
new PurgecssPlugin({
paths: [paths.appHtml, ...glob.sync(`${paths.appSrc}/*`)]


This example is importing the bootstrap css framework. Without purgecss, the base css file size is 138 kB. Using purgecss, the base css file size is 4 kB