Skip to content

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

Variabele: flattenProperty ​

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

Bèta

Maak de flatten-@property PostCSS-plugin.

Doorloopt alle @property at-regels in de stylesheet, extraheert elk initial-value-descriptor, verwijdert de at-regel en voegt vooraan één injectSelector { --name: value; … }-regel in die alle geëxtraheerde declaraties bevat. Lege regels en @layer-blokken die na verwijdering achterblijven, worden verwijderd.

Type Declaration ​

Parameters ​

options? ​

FlattenPropertyOptions

FlattenPropertyOptions.

Retourneert ​

Plugin

Een PostCSS plugin.

postcss ​

postcss: true

Vereist marker voor PostCSS-plugin.

Voorbeelden ​

Standaardinjectie in :root

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

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

Injecteer in :scope (voor gebruik binnen scope-blokken)

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