From 51832d4c8a0af4b91e83ea9a964a848005f0af8d Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Fri, 2 Jun 2017 17:23:20 -0400 Subject: [PATCH 1/2] allow datauri option on js api --- lib/svgo.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/svgo.js b/lib/svgo.js index 4c2167905..5c33972bb 100644 --- a/lib/svgo.js +++ b/lib/svgo.js @@ -14,6 +14,7 @@ var CONFIG = require('./svgo/config.js'), SVG2JS = require('./svgo/svg2js.js'), PLUGINS = require('./svgo/plugins.js'), JSAPI = require('./svgo/jsAPI.js'), + encodeSVGDatauri = require('./svgo/tools.js').encodeSVGDatauri, JS2SVG = require('./svgo/js2svg.js'); var SVGO = module.exports = function(config) { @@ -41,6 +42,9 @@ SVGO.prototype.optimize = function(svgstr) { prevResultSize = svgjs.data.length; this._optimizeOnce(svgjs.data, optimizeOnceCallback); } else { + if (config.datauri) { + svgjs.data = encodeSVGDatauri(svgjs.data, config.datauri); + } resolve(svgjs); } }; From 91a6804cb9c8c66039c08d234a6f4c89325c162f Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Fri, 2 Jun 2017 17:30:05 -0400 Subject: [PATCH 2/2] add datauri configuration parameter --- lib/svgo/config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/svgo/config.js b/lib/svgo/config.js index fc4e2a084..767dace9d 100644 --- a/lib/svgo/config.js +++ b/lib/svgo/config.js @@ -40,6 +40,10 @@ module.exports = function(config) { }); } + if ('datauri' in config) { + defaults.config = config.datauri; + } + if (Array.isArray(defaults.plugins)) { defaults.plugins = optimizePluginsArray(defaults.plugins); }