PurgeCSS 类
用于实例化 PurgeCSS 的类,然后可用于清除 CSS 文件。
签名
declare class PurgeCSS
示例
await new PurgeCSS().purge({
content: ['index.html'],
css: ['css/app.css']
})
属性
| 属性 | 修饰符 | 类型 | 说明 |
|---|---|---|---|
| options | 选项 | ||
| removedNodes | postcss.Node[] | ||
| selectorsRemoved | Set<string> | ||
| variablesStructure | VariablesStructure |
方法
| 方法 | 修饰符 | 说明 |
|---|---|---|
| extractSelectorsFromFiles(files, extractors) | 使用 PurgeCSS 提取器从文件中提取选择器 | |
| extractSelectorsFromString(content, extractors) | 使用 PurgeCSS 提取器从传递的字符串中提取选择器 | |
| getPurgedCSS(cssOptions, selectors) | 根据文件获取 CSS 的已清除版本 | |
| purge(userOptions) | 移除未使用的 CSS | |
| removeUnusedCSSVariables() | 移除未使用的 CSS 变量 | |
| removeUnusedFontFaces() | 移除未使用的字体 | |
| removeUnusedKeyframes() | 移除未使用的关键帧 | |
| walkThroughCSS(root, selectors) | 遍历 CSS AST 并移除未使用的 CSS |
