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 Plugin.

postcss

postcss: true

Обов'язковий маркер плагіна PostCSS.

Приклади

Mangle зі значеннями за замовчуванням (--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");