$ npm install @csstools/utilities-for-private-properties
Transpile @private rules and private custom property references.
Add Utilities for Private Properties to your project:
npm install @csstools/utilities-for-private-properties @csstools/css-parser-algorithms @csstools/css-tokenizer postcss --save-dev
import { createPrivatePropertyTranspiler } from '@csstools/utilities-for-private-properties';
const transpiler = createPrivatePropertyTranspiler({ namespace: 'p' });
const registrations = transpiler.transpile(root.nodes);
root.append(...registrations);
Nodes that are substituted into a style rule but are not its children, for example the contents of
an @contents block, can be transpiled in the scope of that style rule:
transpiler.transpile(nodes, { scope: styleRule });
With preserve: true the @private rules are kept and references inside @apply and @contents
blocks are left alone. Transpiled declarations are still hoisted, so the original notation keeps
working where @private is supported.
@property rules are hoisted out of @layer, @media and @supports group rules, and the
@layer, @media and @supports conditions are kept. @container, @scope and
@starting-style do not constrain name-defining at-rules, so registrations inside them are hoisted
without those conditions.
© 2010 - cnpmjs.org x YWFE | Home | YWFE