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

PurgeCSS class

Class used to instantiate PurgeCSS and can then be used to purge CSS files.

Signature:

declare class PurgeCSS 

Example

await new PurgeCSS().purge({
   content: ['index.html'],
   css: ['css/app.css']
})

Properties

Property

Modifiers

Type

Description

options

Options

removedNodes

postcss.Node[]

selectorsRemoved

Set<string>

variablesStructure

VariablesStructure

Methods

Method

Modifiers

Description

extractSelectorsFromFiles(files, extractors)

Extract the selectors present in the files using a PurgeCSS extractor

extractSelectorsFromString(content, extractors)

Extract the selectors present in the passed string using a PurgeCSS extractor

getPurgedCSS(cssOptions, selectors)

Get the purged version of the css based on the files

purge(userOptions)

Remove unused CSS

removeUnusedCSSVariables()

Remove unused CSS variables

removeUnusedFontFaces()

Remove unused font-faces

removeUnusedKeyframes()

Remove unused keyframes

walkThroughCSS(root, selectors)

Walk through the CSS AST and remove unused CSS

Edit this page