Skip to content

pantoken / plugins/postcss/props-minify/src / flattenProperty

Variabel: flattenProperty

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

Beta

Buat plugin PostCSS flatten-@property.

Menelusuri semua at-rule @property dalam stylesheet, mengekstrak setiap deskriptor initial-value, menghapus at-rule tersebut, dan menyisipkan di awal satu aturan injectSelector { --name: value; … } yang berisi semua deklarasi yang diekstrak. Aturan kosong dan blok @layer yang tersisa setelah penghapusan akan dibuang.

Type Declaration

Parameter

options?

FlattenPropertyOptions

FlattenPropertyOptions.

Mengembalikan

Plugin

Sebuah Plugin untuk PostCSS.

postcss

postcss: true

Penanda plugin PostCSS yang diperlukan.

Contoh

Injeksi default ke :root

ts
import postcss from "postcss";
import { flattenProperty } from "@pantoken/plugin-flatten-property";

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

Injeksi ke :scope (untuk digunakan di dalam blok scope)

ts
import postcss from "postcss";
import { flattenProperty } from "@pantoken/plugin-flatten-property";

const out = postcss([flattenProperty({ injectSelector: ":scope" })]).process(css, { from: undefined }).css;
ts
Preserve