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

Home > purgecss > PurgeCSS > purge

PurgeCSS.purge() method

Remove unused CSS

Signature:

purge(userOptions: UserDefinedOptions | string | undefined): Promise<ResultPurge[]>;

Parameters

Parameter

Type

Description

userOptions

UserDefinedOptions | string | undefined

PurgeCSS options or path to the configuration file

**Returns:**

Promise<ResultPurge[]>

an array of object containing the filename and the associated CSS

Example 1

Using a configuration file named purgecss.config.js

const purgeCSSResults = await new PurgeCSS().purge()

Example 2

Using a custom path to the configuration file

const purgeCSSResults = await new PurgeCSS().purge('./purgecss.config.js')

Example 3

Using the PurgeCSS options

const purgeCSSResults = await new PurgeCSS().purge({
   content: ['index.html', '**\/*.js', '**\/*.html', '**\/*.vue'],
   css: ['css/app.css']
})
Edit this page