プリセット
プリセットは、メイン構成にマージされる部分的な構成です。
プリセットを作成する場合、通常はプリセット固有のいくつかのオプションを要求できるコンストラクタ関数を出力します。例
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 */ }),
],
})
公式プリセットとコミュニティープリセットで、その他の例を確認できます。