Skip to content

pantoken / props-minify

props-minify

เบต้า

@pantoken/plugin-props-minify — รวมการแปลง prune, flatten และ mangle สำหรับ --instui-* custom properties ผ่านยูทิลิตี้เดียว applyMinify.

Each CSS-emitting pipeline (generate scripts, renderers) uses applyMinify for a consistent minification surface without taking a direct PostCSS dependency.

Prune + mangle are only safe for self-contained bundles where all var(--instui-*) references and their definitions live in the same output. For separate-file consumers (@pantoken/css + @pantoken/components loaded independently), apply { flatten: true } only.

Mangle across file boundaries: pass the same Map instance as mangle.sharedManifest to every applyMinify call that processes CSS files loaded together. Process the token sheet first (it seeds the manifest), then component sheets.

ตัวอย่าง

ใช้การแปลงทั้งสามอย่างกับบันเดิลที่เป็น self-contained

ts
import { applyMinify } from "@pantoken/plugin-props-minify";
const out = applyMinify(css, { prune: true, flatten: true, mangle: true });

ใช้เฉพาะ Flatten (ปลอดภัยสำหรับผู้ใช้แบบไฟล์แยก)

ts
import { applyMinify } from "@pantoken/plugin-props-minify";
const out = applyMinify(css, { flatten: true });

Mangle สองไฟล์ด้วยแมปเดียวกัน

ts
import { applyMinify } from "@pantoken/plugin-props-minify";
const manifest = new Map<string, string>();
const tokenCss = applyMinify(rawTokens, { mangle: { sharedManifest: manifest } });
const componentCss = applyMinify(rawComponents, { mangle: { sharedManifest: manifest } });

อินเทอร์เฟซ

นามแฝงชนิด

ตัวแปร

ฟังก์ชัน