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

PropertyModifiersTypeDescription
optionsOptions
removedNodespostcss.Node[]
selectorsRemovedSet<string>
variablesStructureVariablesStructure

Methods

MethodModifiersDescription
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