# WordPress

If you want to use PurgeCSS with WordPress, you might need to safelist classes generated by WordPress to avoid them being removed by PurgeCSS. purgecss-with-wordpress contains the classes needed to be safelisted.

# Installation

You need to install purgecss (opens new window) first.

Install purgecss-with-wordpress:

npm i --save-dev purgecss-with-wordpress
1

# Usage


 




 
 


import Purgecss from 'purgecss'
import purgecssWordpress from 'purgecss-with-wordpress'

const purgeCss = new Purgecss({
  content: ['**/*.html'],
  css: ['**/*.css'],
  safelist: purgecssWordpress.safelist
})
const result = purgecss.purge()
1
2
3
4
5
6
7
8
9

If you have additional classes you want to include, you can include them using the spread operator:

{
  safelist: [
    ...purgecssWordpress.safelist,
    'red',
    'blue',
    /^red/,
    /blue$/,
  ]
}
1
2
3
4
5
6
7
8
9