greglebreton 4e8a693745
Some checks failed
continuous-integration/drone/push Build is failing
add garagenum exp + maj url site projets
2023-01-08 16:50:31 +01:00

29 lines
633 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = minifySvg;
var _helpers = require("../helpers");
const svgo = (0, _helpers.optionalRequire)('svgo');
/** Minify SVG with SVGO */
function minifySvg(tree, options, svgoOptions = {}) {
if (!svgo) return tree;
tree.match({
tag: 'svg'
}, node => {
let svgStr = tree.render(node, {
closingSingleTag: 'slash',
quoteAllAttributes: true
});
const result = svgo.optimize(svgStr, svgoOptions);
node.tag = false;
node.attrs = {};
node.content = result.data;
return node;
});
return tree;
}