Package Exports
- postcss-variables
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-variables) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
PostCSS Variables
Converts variables into CSS.
/* before (nesting requires postcss-nested) */
$dir: assets/icons;
$color: blue;
.block {
background: url('$(dir)/foo.png');
&__elem {
$color: green;
color: $color;
}
&__elem2 {
color: $color;
}
}
/* after */
.block {
background: url('assets/icons/foo.png');
&__elem {
color: green;
}
&__elem2 {
color: blue;
}
}Usage
Add PostCSS Variables to your build tool:
npm install postcss-variables --save-devNode
require('postcss-variables')({ /* options */ }).process(YOUR_CSS);PostCSS
Add PostCSS to your build tool:
npm install postcss --save-devLoad PostCSS Variables as a PostCSS plugin:
postcss([
require('postcss-variables')({ /* options */ })
]);Options
globals
Type: Object
Default: {}
Specifies your own global variables.
require('postcss-variables')({
globals: {
siteWidth: '960px',
colors: {
primary: '#fff',
secondary: '#000'
}
}
});/* before */
.hero {
color: $colors.primary;
max-width: $siteWidth;
}
/* after */
.hero {
color: #fff;
max-width: 960px;
}Note: Please refer to Advanced Variables for more advanced features. This library is essentially a simplification and alteration of that plugin. Thank you to the author for making it available.