Skip to content

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

Variabel: mangleCustomProps

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

Beta

Buat plugin PostCSS mangle-custom-properties.

Mengumpulkan semua nama properti kustom yang cocok dengan prefix dari properti deklarasi, var() references, dan @property params. Mengurutkannya secara alfabet untuk pemetaan yang stabil dan deterministik, lalu menetapkan nama pendek menggunakan method yang dipilih. Mengganti setiap kemunculan di seluruh stylesheet.

Type Declaration

Parameter

options?

MangleCustomPropsOptions

MangleCustomPropsOptions.

Mengembalikan

Plugin

Sebuah Plugin untuk PostCSS.

postcss

postcss: true

Penanda plugin PostCSS yang diperlukan.

Contoh

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

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

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

Bagikan pemetaan di antara dua file yang dimuat 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");