Version: 2.0.5
Run npm install node-px2rem
'use strict';
const fs = require('fs');
const px2rem = require('node-px2rem');
const css = fs.readFileSync('main.css', 'utf8');
const processedCSS = px2rem.process(css, {
rootValue: 16
});
fs.writeFile('main-rem.css', processedCSS, (err) => {
if (err) {
throw err;
}
console.log('Done.');
});
Type: Object | Null
Default:
{
rootValue: 16,
unitPrecision: 5,
propertyBlackList: [],
propertyWhiteList: [],
replace: false,
mediaQuery: false,
minPx: 1
}
rootValue
(Number) The root element font size.unitPrecision
(Number) The decimal numbers to allow the REM units to grow to.propertyBlackList
(Array) The properties that can't change from px to rem.propertyWhiteList
(Array) The properties that can change from px to remreplace
(Boolean) Replaces rules containing rems instead of adding fallbacks.mediaQuery
(Boolean) Allow px to be converted in media queries.minPx
(Number) If minimum px greater than or equal can change from px to rem.
MIT © 2021 Gergely Kovács (gg.kovacs@gmail.com)