svgcss
v0.3.0
Published
Embed SVG files in CSS as data URIs with PNG fallback.
Downloads
2
Readme
SVGCSS
Embed SVG files in CSS as data URIs with PNG fallback.
API
var svgcss = require('svgcss');
var options = {
source: 'images/*.svg',
destination: 'css/images.css'
};
var callback = function (err, result) {
// do something with result
};
svgcss(options, callback);
options
The first argument to svgcss
is an options object which can have any of the following properties:
source
: glob that should match the svg files that should be used.destination
: the file path where the CSS will be written.fallback
: Whentrue
or a file path, converts _SVG_s to PNG and creates an additional CSS file with the PNG URIs embedded. Defaults tofalse
.namespace
: used to prefix CSS class names. Defaults toicon
.data
: if present, gets passed as data to the templating method together with each SVG file.process
: override the function that generates theCSS
code. Animage
object withname
,namespace
,width
,height
anduri
is passed in.
callback
The callback receives an error object or null
as the first argument. The second argument is an array of of objects, one for each SVG source file, with name
, namespace
, width
, height
, uri
, css
and optionally fallbackCSS
properties.