Skip to content

pantoken-root / plugins/postcss/flatten-property/src / flattenProperty

Variabel: flattenProperty ​

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

Beta

Skapa PostCSS-pluginen flatten-@property.

Traverserar alla @property at-regler i stylesheetet, extraherar varje initial-value-beskrivare, tar bort the at-rule, och förinserterar en enda injectSelector { --name: value; … }-regel som innehåller alla extraherade deklarationer. Tomma regler och @layer-block som blir kvar efter borttagning tas bort.

Type Declaration ​

Parametrar ​

options? ​

FlattenPropertyOptions

FlattenPropertyOptions.

Returnerar ​

Plugin

Ett PostCSS tillägg.

postcss ​

postcss: true

Obligatorisk PostCSS-pluginmarkör.

Exempel ​

Standardinjektion i :root

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

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

Injicera i :scope (för användning inom scope-block)

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