rework-rem-fallback

Add pixel fallback to CSS rules using rem units

rework-rem-fallback

A Rework plugin to add pixel fallback for properties using rem units. This is a build time workaround for browsers that don't understand the rem unit. (cough IE<9)

npm install rework-rem-fallback

As a Rework plugin:

// dependencies 
var fs = require('fs');
var rework = require('rework');
var remFallback = require('rework-rem-fallback');
 
// css to be processed 
var css = fs.readFileSync('build/build.css', 'utf8').toString();
 
// process css using rework-rem-fallback (default base 16px) 
var out = rework(css).use(remFallback()).toString();
 
// process css using rework-rem-fallback (custom base 14px) 
var out14 = rework(css).use(remFallback(14)).toString();
.main-header {
  width: 5rem;
}

yields:

.main-header {
  width: 80px;
  width: 5rem;
}

MIT License