跳到主要内容

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 i -D @fullhuman/postcss-purgecss

and add the PurgeCSS plugin to the PostCSS configuration:

const purgecss = require('@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: