Skip to content

pantoken-root / plugins/postcss/props-minify/src / mangleCustomProps

Variabel: mangleCustomProps ​

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

Beta

Skapa PostCSS-pluginet mangle-custom-properties.

Samlar alla anpassade egenskapsnamn som matchar prefix från deklarationsprops, var()-referenser, och @property-parametrar. Sorterar dem alfabetiskt för en stabil, deterministisk mappning, och tilldelar korta namn med hjälp av den valda method. Ersätter varje förekomst i hela stylesheetet.

Type Declaration ​

Parametrar ​

options? ​

MangleCustomPropsOptions

MangleCustomPropsOptions.

Returnerar ​

Plugin

Ett PostCSS tillägg.

postcss ​

postcss: true

Obligatorisk PostCSS-pluginmarkör.

Exempel ​

Mangle med standardinställningar (--instui-\*, base26)

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

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

Dela mappningen mellan två filer som laddas tillsammans

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

Använd base36-namn och skriv ut mappningen via 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");