Skip to content

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

Variável: mangleCustomProps

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

Beta

Criar o plugin PostCSS mangle-custom-properties.

Coleta todos os nomes de propriedades customizadas que correspondem a prefix de props de declaração, var() referências, e @property params. Ordena-os alfabeticamente para um mapeamento estável e determinístico, então atribui nomes curtos usando o method escolhido. Substitui cada ocorrência por toda a folha de estilos.

Type Declaration

Parâmetros

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Retorna

Plugin

Um Plugin do PostCSS.

postcss

postcss: true

Marcador obrigatório do plugin PostCSS.

Exemplos

Ofuscar com padrões (--instui-\*, base26)

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

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

Compartilhar o mapeamento entre dois arquivos carregados 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 nomes em base36 e emitir o mapeamento 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");