postcss-global-vars
PostCSS plugin to declare global variables, accepts some internal references.
It’s based on postcss-external-vars
plugin, some kind of fork, but totally rewritten in TypeScript.
The main idea is to allow internal references (use some variables in the value of other variables).
Also, it can process variables in media-queries.
Example
Input:
{/ 2);}
Data:
Output:
{/ 2);}
Install
npm install --save-dev postcss-global-vars
Usage
const postcss = ;const globalVars = default; const data = colors: main: 'red' lighter: 'color($global.colors.main l(+30%))' ; const css = '.test {color: $global.colors.main; background: $global.colors.lighter;}'; const result = css; console; // => '.test {color: red; background: color(red l(+30%));}'
Options
prefix
Type: string
Default: '$global.'
A prefix for global variable name.
data
Type: object
Default: {data:{}}
Data to be used as global variables.
Interface:
Change Log
License
MIT.