Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
/ SvgToCSS Public archive

renders SVG in CSS file using data URIs or base64

Notifications You must be signed in to change notification settings

kajyr/SvgToCSS

Repository files navigation

SvgToCSS

Build Status

The idea behind this module came from the work made for aditollo/grunt-svgzr and the probably-dont-base64-svg article

I've decided to separate the URI / base64 svg renderer to generate CSS / SCSS sprites from SVG files.

Usage

var svgtocss = require('svgtocss');

svgtocss.encode(['file1.svg', 'file2.svg'], options).then(function() {
	console.log('all done!');
})

This task would have created a css file like this

.svg-file1 {
	background-image: url('data:image/svg+xml;charset=utf-8, ...');
}

.svg-file2 {
	background-image: url('data:image/svg+xml;charset=utf-8, ... ');
}

Options

The options parameter can accept these configs:

  • base64: boolean, should compress image in base64? (default: false)
  • cwd: string, the directory to output files (default: './')
  • style: string, css or scss. That changes the output syntax.
  • sprite: string, the file to output. (default: 'svg.css')

About

renders SVG in CSS file using data URIs or base64

Resources

Stars

Watchers

Forks

Packages

No packages published