Skip to content

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

משתנה: mangleCustomProps ​

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

בטא

צור את פלאגין PostCSS בשם mangle-custom-properties.

אוסף את כל שמות ה‑custom properties המתאימים ל‑prefix מ‑declaration props, var() references, ו‑@property params. ממיין אותם לפי סדר אלפביתי למיפוי יציב ודטרמיניסטי, ואז מקצה שמות קצרים באמצעות ה‑method הנבחר. מחליף כל הופעה ברחבי גיליון הסגנון.

Type Declaration ​

פרמטרים ​

options? ​

MangleCustomPropsOptions

MangleCustomPropsOptions.

מחזיר ​

Plugin

תוסף של PostCSS תוסף.

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");