Home > purgecss > PurgeCSS > purge

PurgeCSS.purge() method

Remove unused CSS

Signature:

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

Parameters

ParameterTypeDescription
userOptionsUserDefinedOptions | string | undefinedPurgeCSS 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']
})