Skip to content

pantoken-root / props-minify

props-minify ​

เบต้า

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

แต่ละไพป์ไลน์ที่สร้าง CSS (generate scripts, renderers)) ใช้ applyMinify เพื่อพื้นผิวที่สอดคล้อง การย่อขนาดโดยไม่ต้องพึ่งพา PostCSS โดยตรง.

Prune + mangle ปลอดภัยเฉพาะกับบันเดิลที่เป็นเอกเทศ ซึ่งการอ้างอิงทั้งหมด var(--instui-*) และคำจำกัดความของพวกมันอยู่ในเอาต์พุตชุดเดียวกัน สำหรับผู้บริโภคที่แยกไฟล์ (@pantoken/css + @pantoken/components ที่โหลดแยกกัน)), ให้ใช้ { flatten: true } เท่านั้น.

การ mangle ข้ามขอบเขตไฟล์: ส่งผ่านอินสแตนซ์ Map เดียวกันเป็น mangle.sharedManifest ไปยังการเรียก applyMinify ทุกครั้งที่ประมวลผลไฟล์ CSS ที่โหลดร่วมกัน. ประมวลผลชีตโทเค็นก่อน (มันเป็นเมล็ดสำหรับ manifests)), จากนั้นจึงประมวลผลชีตของคอมโพเนนต์.

ตัวอย่าง ​

ใช้การแปลงทั้งสามอย่างกับบันเดิลที่เป็น 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 } });

อินเทอร์เฟซ ​

นามแฝงชนิด ​

ตัวแปร ​

ฟังก์ชัน ​