PurgeCSSPurgeCSS
API Reference
GitHub
API Reference
GitHub
  • PurgeCSS

    • About PurgeCSS
    • Getting Started
    • Configuration
    • Command Line Interface
    • Programmatic API
    • Safelisting
    • Extractors
  • Plugins

    • PostCSS
    • Webpack
    • Gulp
    • Grunt
    • Gatsby
  • Guides

    • Vue
    • React
    • Next.js
    • Nuxt.js
    • Razzle
    • WordPress
    • Hugo
  • Comparison
  • Common Questions

    • How to use with CSS modules
    • How to use with Ant Design

Getting Started

Most bundlers and frameworks to build websites are using PostCSS. The easiest way to configure PurgeCSS is with its PostCSS plugin.

Install the PostCSS plugin:

npm
npm i -D @fullhuman/postcss-purgecss
yarn
yarn add @fullhuman/postcss-purgecss --dev

and add the PurgeCSS plugin to the PostCSS configuration:

import { purgeCSSPlugin } from '@fullhuman/postcss-purgecss';

module.exports = {
  plugins: [
    purgecss({
      content: ['./**/*.html']
    })
  ]
}

PurgeCSS will remove the CSS that is not in the files specified in the content option.

You can find more information about PostCSS plugin and the configuration options on the following pages:

  • PostCSS plugin
  • Configuration
Edit this page
Last Updated:
Contributors: Floriel
Prev
About PurgeCSS
Next
Configuration