PostCSS Unit Conversion
PostCSS plugin for converting units from px to em or rem. Removes the need for using scss mixins like em()
or rem()
. Write in px and convert on the fly.
Usage
Add to project via from postcss-unit-conversion on npm and set options below.
$ npm install --save-dev postcss-unit-conversion
And add to your project and requrire.
;
Set optional options (defaults below).
var options =base: 16precision: 3toEM:'letter-spacing''text-shadow'toREM:'box-shadow''font-size''margin''padding';
Anything not added to either toEM
or toREM
will retain px (or supplied) values.
Conversion
In
Out
Testing
Run
$ npm run test
Tests the code example above. Will test against options provided in your post css setup.
See PostCSS docs for examples for your environment.
Roadmap
- Add ignore option to ignore conversion of certain elements or classes.
- Webpack testing and support.