Skip to content

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

Variable: mangleCustomProps ​

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

Beta

Crear el plugin PostCSS mangle-custom-properties.

Recopila todos los nombres de propiedades personalizadas que coinciden con prefix de las propiedades de declaración, referencias var(), y parámetros @property. Los ordena alfabéticamente para obtener un mapeo estable y determinista, luego asigna nombres cortos usando el method elegido. Reemplaza cada ocurrencia en toda la hoja de estilos.

Type Declaration ​

Parámetros ​

options? ​

MangleCustomPropsOptions

MangleCustomPropsOptions.

Devuelve ​

Plugin

Un Plugin de PostCSS.

postcss ​

postcss: true

Marcador requerido para el plugin de PostCSS.

Ejemplos ​

Ofuscar con valores predeterminados (--instui-\*, base26)

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

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

Compartir el mapeo entre dos archivos cargados juntos

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

Usar nombres base36 y emitir el mapeo vía 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");