postcss-base64
Advanced tools
Comparing version 0.1.3 to 0.2.0
14
index.js
@@ -5,6 +5,14 @@ var postcss = require('postcss'); | ||
return function (css, result) { | ||
opts = opts || { debug: false }; | ||
var output; | ||
opts = opts || { | ||
debug: false, | ||
pattern: '<svg.*<\/svg>' | ||
}; | ||
css.replaceValues(/<svg.*<\/svg>/, { fast: '<svg' }, function (string) { | ||
var output, search; | ||
if(!opts.pattern) throw new Error('No search pattern given.'); | ||
search = new RegExp(opts.pattern); | ||
css.replaceValues(search, function (string) { | ||
output = 'data:image/svg+xml;base64,' + new Buffer(string).toString('base64'); | ||
@@ -11,0 +19,0 @@ if(opts.debug) { |
{ | ||
"name": "postcss-base64", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Replace *inline* SVG images in url() statements with base64 encoded strings.", | ||
@@ -5,0 +5,0 @@ "author": "Jelmer de Maat", |
@@ -8,3 +8,4 @@ var fs = require('fs'), | ||
var opts = { | ||
debug: false | ||
debug: true, | ||
pattern: '<svg.*<\/svg>' | ||
}; | ||
@@ -11,0 +12,0 @@ |
3258
50