Skip to content

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

Variabel: mangleCustomProps

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

Beta

Lag PostCSS-pluggen mangle-custom-properties.

Samlar alle eigne eigenskapnamn som samsvarar med prefix frå deklarasjons-props, var()-referansar, og @property-parametrar. Sorterer dei alfabetisk for ei stabil, deterministisk kartlegging, og tildeler deretter korte namn med den valde method. Erstattar kvar førekome i heile stilarket.

Type Declaration

Parametrar

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Returnerer

Plugin

Ein PostCSS plugin.

postcss

postcss: true

Nødvendig PostCSS-pluginmarkør.

Døme

Mangle med standardinnstillingar (--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 kartlegginga mellom to filer som blir lasta inn 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

Bruk base36-namn og send ut kartlegginga 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");