Skip to content

pantoken / packages/plugin-kit/src / checkPlugins

Funzione: checkPlugins()

checkPlugins(plugins, stage): PantokenPlugin[]

Beta

Filtra un elenco di plugin per quelli che partecipano a stage, avvisando sugli altri.

Parametri

plugins

readonly PantokenPlugin[]

I plugin registrati.

stage

Stage

La fase in esecuzione.

Restituisce

PantokenPlugin[]

I plugin che hanno un hook per stage.

Esempio

Mantieni solo i plugin che partecipano a una fase

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]