Skip to content

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

Pembolehubah: mangleCustomProps ​

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

Beta

Buat pemalam PostCSS mangle-custom-properties.

Mengumpulkan semua nama sifat tersuai yang sepadan dengan prefix dari props deklarasi, var() rujukan, dan parameter @property. Menyusunnya mengikut abjad untuk pemetaan yang stabil dan deterministik, kemudian memberi nama pendek menggunakan method yang dipilih. Menggantikan setiap kejadian di seluruh helaian gaya.

Type Declaration ​

Parameter ​

options? ​

MangleCustomPropsOptions

MangleCustomPropsOptions.

Mengembalikan ​

Plugin

Sebuah PostCSS Plugin.

postcss ​

postcss: true

Penanda plugin PostCSS yang diperlukan.

Contoh ​

Mangle dengan lalai (--instui-\*, base26)

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

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

Kongsi pemetaan merentasi dua fail yang dimuatkan bersama

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

Gunakan nama base36 dan keluarkan pemetaan melalui 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");