預設集
預設集是部分設定,將會合併到主要設定中。
在撰寫預設集時,我們通常會匯出一個建構函式,您可以要求一些預設集特定的選項。例如:
ts
import { definePreset, Preset } from 'unocss'
export default definePreset((options?: MyPresetOptions) => {
return {
name: 'my-preset',
rules: [
// ...
],
variants: [
// ...
],
// it supports most of the configuration you could have in the root config
}
})
然後使用者可以像這樣使用它:
ts
import { defineConfig } from 'unocss'
import myPreset from './my-preset'
export default defineConfig({
presets: [
myPreset({ /* preset options */ }),
],
})