svgcss

0.3.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i svgcss

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • iclanzan