Skip to content

pantoken / packages/plugin-kit/src / checkPlugins

函式: checkPlugins()

checkPlugins(plugins, stage): PantokenPlugin[]

Beta(測試)

篩選外掛清單,僅保留參與 stage 的外掛,並對其餘的發出警告。

參數

plugins

唯讀 PantokenPlugin[]

已註冊的外掛。

stage

Stage

正在執行的階段。

回傳

PantokenPlugin[]

具有 stage 鉤子的外掛。

範例

僅保留參與該階段的外掛

ts
import { checkPlugins, definePlugin } from "@pantoken/plugin-kit";

const tokensOnly = definePlugin({ name: "tok", tokens: (c) => c.tokens });
const cssOnly = definePlugin({ name: "styles", css: () => ({ append: "" }) });

// Warns that "tok" has no css hook, then returns just the css plugin.
checkPlugins([tokensOnly, cssOnly], "css"); // → [cssOnly]