Pleeease: filters
Convert CSS shorthand filters to SVG equivalents.
Used by Pleeease, a CSS post-processor.
##Example
You write foo.css
:
.blur {
filter: blur(4px);
}
You get bar.css
:
.blur {
filter: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feGaussianBlur stdDeviation="4" /></filter></svg>#filter');
filter: blur(4px);
}
##Usage
$ npm install pleeease-filters
var filters = require('pleeease-filters'),
fs = require('fs');
var css = fs.readFileSync('app.css', 'utf8');
var options = {};
var fixed = filters.process(css, options);
fs.writeFile('app.min.css', fixed, function (err) {
if (err) {
throw err;
}
console.log('File saved!');
});
##Options
You can also add IE filters with an option:
var options = {
oldIE: true
}
Using the first example, you'll get:
.blur {
filter: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feGaussianBlur stdDeviation="4" /></filter></svg>#filter');
filter: blur(4px);
filter: progid:DXImageTransform.Microsoft.Blur(pixelradius=4);
}
##Note
Be careful, not all browsers support CSS or SVG filters. For your information, latest WebKit browsers support CSS shorthand, Firefox support SVG filters and IE9- support IE filters (limited and slightly degraded). It means that IE10+, Opera Mini and Android browsers have no support at all. Moreover, IE filters shouldn't be used.
##Licence
MIT © 2014 Vincent De Oliveira · iamvdo
This module is an adaptation of CSS-Filters-Polyfill. Copyright (c) 2012 - 2013 Christian Schepp Schaefer