Skip to content

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

Breytur: mangleCustomProps ​

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

Beta

Búa til mangle-custom-properties PostCSS viðbót.

Safnar öllum sérsniðnu eignanöfnum sem passa við prefix úr tilkynningareiginleikum, var() tilvísunum, og @property parametrum. Raðar þeim stafrófsröð fyrir stöðuga, ákvörðaða mappun, og úthlutar stuttum nöfnum með valda method. Skiptir út hverri forekomst um allt stílsniðið.

Type Declaration ​

Færibreytur ​

options? ​

MangleCustomPropsOptions

MangleCustomPropsOptions.

Skilar ​

Plugin

PostCSS viðbót.

postcss ​

postcss: true

Krafist merkis fyrir PostCSS-viðbót.

Dæmi ​

Dulnefna með sjálfgefnum stillingum (--instui-*, base26)

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

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

Deila mappun á milli tveggja skráa sem eru hlaðin saman

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

Nota base36 nöfn og senda mappunina í gegnum 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");