Skip to content

pantoken / plugins/postcss/mangle-custom-props/src / mangleCustomProps

Variabile: mangleCustomProps

const mangleCustomProps: {(options?): Plugin; postcss: true; }

Beta

Crea il plugin PostCSS mangle-custom-properties.

Raccoglie tutti i nomi di proprietà personalizzate corrispondenti a prefix dalle proprietà delle dichiarazioni, dai riferimenti var() e dai parametri @property. Li ordina alfabeticamente per una mappatura stabile e deterministica, quindi assegna nomi brevi usando il method scelto. Sostituisce ogni occorrenza in tutto il foglio di stile.

Type Declaration

Parametri

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Restituisce

Plugin

Un Plugin per PostCSS.

postcss

postcss: true

Marcatore obbligatorio del plugin PostCSS.

Esempi

Mangle con impostazioni predefinite (--instui-\*, base26)

ts
import postcss from "postcss";
import { mangleCustomProps } from "@pantoken/plugin-mangle-custom-props";

const out = postcss([mangleCustomProps()]).process(css, { from: undefined }).css;

Condividi la mappatura tra due file caricati insieme

ts
import postcss from "postcss";
import { mangleCustomProps } from "@pantoken/plugin-mangle-custom-props";

const manifest = new Map<string, string>();
const tokenCss = postcss([mangleCustomProps({ sharedManifest: manifest })]).process(tokens, { from: undefined }).css;
const componentCss = postcss([mangleCustomProps({ sharedManifest: manifest })]).process(components, { from: undefined }).css;
// both files use the same --instui-* → --a mapping

Usa nomi base36 ed emetti la mappatura tramite result.messages

ts
import postcss from "postcss";
import { mangleCustomProps } from "@pantoken/plugin-mangle-custom-props";

const result = postcss([mangleCustomProps({ method: "base36", propertyMap: true })]).process(css, { from: undefined });
const msg = result.messages.find((m) => m.type === "mangle-map");