postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
597 stars 77 forks source link

[Feature request] Option for adding prefix/suffix to custom property names #217

Open SevenOutman opened 4 years ago

SevenOutman commented 4 years ago

I'm writing styles for a react component library and we're going to adopt custom properties. One thing I'm worrying is that global custom properties defined in my library may pollute those in the user application. One possible solution is adding a unique prefix for every custom properties in my library, e.g. --btn-bg -> --rs-btn-bg. So I wonder if I can have this option that allow adding prefixes/suffixes.

API Proposal

renameProperties: { test: RegExp, handler(originalName: string) => string }

Allows user to rename properties that matches the pattern they want.

prefix: string/suffix: string

Short for predefined renaming rules with '*' test pattern.