Skip to content

Commit

Permalink
Merge pull request svg#735 from vcanales/feature/datauri-api
Browse files Browse the repository at this point in the history
Allow datauri option on js api
  • Loading branch information
GreLI authored Jun 13, 2017
2 parents 718d576 + 91a6804 commit 8947cc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/svgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
};
Expand Down
4 changes: 4 additions & 0 deletions lib/svgo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8947cc5

Please sign in to comment.