0.3.0 • Published 9 years ago

svgcss v0.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

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: When true or a file path, converts SVG_s to _PNG and creates an additional CSS file with the PNG URIs embedded. Defaults to false.
  • namespace: used to prefix CSS class names. Defaults to icon.
  • data: if present, gets passed as data to the templating method together with each SVG file.
  • process: override the function that generates the CSS code. An image object with name, namespace, width, height and uri 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.