Skip to content

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

Variabel: mangleCustomProps

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

Beta

Opprett PostCSS-pluginen mangle-custom-properties.

Samler alle egendefinerte egenskapsnavn som matcher prefix fra deklarasjonsprops, var()-referanser, og @property-parametere. Sorterer dem alfabetisk for en stabil, deterministisk kartlegging, og tilordner korte navn ved hjelp av valgte method. Erstatter alle forekomster i hele stilarket.

Type Declaration

Parametere

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Returnerer

Plugin

En PostCSS plugin.

postcss

postcss: true

Påkrevd PostCSS-pluginmarkør.

Eksempler

Mangle med standardinnstillinger (--instui-\*, base26)

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

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

Del kartleggingen mellom to filer som lastes sammen

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

Bruk base36-navn og inkluder kartleggingen i 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");