Skip to content

提取器

¥Extractors

提取器用于从源代码中提取工具的使用情况。

¥Extractors are used to extract the usage of utilities from your source code.

ts
// uno.config.ts
import { defineConfig } from 'unocss'

export default defineConfig({
  extractors: [
    // your extractors
  ],
})

默认情况下,始终应用 extractorSplit,它将源代码拆分为令牌并直接提供给引擎。

¥By default extractorSplit will always be applied, which splits the source code into tokens and directly feed to the engine.

要覆盖默认提取器,你可以使用 extractorDefault 选项。

¥To override the default extractors, you can use extractorDefault option.

ts
// uno.config.ts
import { defineConfig } from 'unocss'

export default defineConfig({
  extractors: [
    // your extractors
  ],
  // disable the default extractor
  extractorDefault: false,
  // override the default extractor with your own
  extractorDefault: myExtractor,
})

例如,请检查 Pug 提取器属性提取器 的实现。

¥For example, please check the implementation of pug extractor or the attributify extractor.