Skip to content

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

Переменная: mangleCustomProps

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

Бета

Создать плагин PostCSS mangle-custom-properties.

Собирает все имена пользовательских свойств, соответствующие prefix, из свойств деклараций, ссылок var() и параметров @property. Сортирует их в алфавитном порядке для получения стабильного детерминированного отображения, затем назначает короткие имена, используя выбранный method. Заменяет каждое вхождение по всему стилевому файлу.

Type Declaration

Параметры

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Возвращаемое значение

Plugin

Плагин PostCSS плагин.

postcss

postcss: true

Обязательный маркер плагина PostCSS.

Примеры

Перемешивать по умолчанию (--instui-\*, base26)

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

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

Совместно использовать отображение между двумя файлами, загружаемыми вместе

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

Использовать имена в base36 и выводить отображение через 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");