2021-02-22 21:40:15 +01:00
|
|
|
/*
|
2021-01-11 11:08:40 +01:00
|
|
|
const plugins = [
|
2021-01-13 10:46:24 +01:00
|
|
|
{removeDimensions: true},
|
|
|
|
{removeScriptElement: true},
|
|
|
|
{removeViewBox: false},
|
|
|
|
{moveElemsAttrsToGroup: false},
|
2021-01-14 22:47:03 +01:00
|
|
|
{convertStyleToAttrs: false},
|
2021-02-16 17:19:26 +01:00
|
|
|
{removeUselessDefs: false},
|
2021-01-13 13:32:53 +01:00
|
|
|
{convertPathData: {
|
|
|
|
lineShorthands: false,
|
|
|
|
curveSmoothShorthands: false,
|
|
|
|
forceAbsolutePath: true,
|
|
|
|
}}
|
2021-01-11 11:08:40 +01:00
|
|
|
];
|
2021-02-22 21:40:15 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
const plugins = [
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'removeDoctype',
|
|
|
|
// 'removeXMLProcInst',
|
|
|
|
// 'removeComments',
|
|
|
|
// 'removeMetadata',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'removeXMLNS',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'removeEditorsNSData',
|
|
|
|
// 'cleanupAttrs',
|
|
|
|
// 'inlineStyles',
|
|
|
|
// 'minifyStyles',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'convertStyleToAttrs'
|
2021-02-23 10:11:43 +01:00
|
|
|
// 'cleanupIDs',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'prefixIds',
|
|
|
|
// 'removeRasterImages',
|
|
|
|
// 'removeUselessDefs',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'cleanupNumericValues',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'cleanupListOfValues',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'convertColors',
|
|
|
|
// 'removeUnknownsAndDefaults',
|
|
|
|
// 'removeNonInheritableGroupAttrs',
|
|
|
|
// 'removeUselessStrokeAndFill',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'removeViewBox',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'cleanupEnableBackground',
|
|
|
|
// 'removeHiddenElems',
|
|
|
|
// 'removeEmptyText',
|
|
|
|
// 'convertShapeToPath',
|
|
|
|
// 'convertEllipseToCircle',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'moveElemsAttrsToGroup',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'moveGroupAttrsToElems',
|
2021-02-23 10:11:43 +01:00
|
|
|
// 'collapseGroups',
|
2021-02-25 09:41:57 +01:00
|
|
|
// {'convertPathData': {
|
|
|
|
// 'lineShorthands': false,
|
|
|
|
// 'curveSmoothShorthands': false,
|
|
|
|
// 'forceAbsolutePath': true,
|
|
|
|
// }},
|
|
|
|
// 'convertTransform',
|
|
|
|
// 'removeEmptyAttrs',
|
|
|
|
// 'removeEmptyContainers',
|
|
|
|
// 'mergePaths',
|
|
|
|
// 'removeUnusedNS',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'sortAttrs',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'sortDefsChildren',
|
|
|
|
// 'removeTitle',
|
|
|
|
// 'removeDesc',
|
|
|
|
// 'removeDimensions',
|
|
|
|
// 'removeAttrs',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'removeAttributesBySelector',
|
|
|
|
// 'removeElementsByAttr',
|
|
|
|
// 'addClassesToSVGElement',
|
2021-02-25 09:41:57 +01:00
|
|
|
// 'removeStyleElement',
|
|
|
|
// 'removeScriptElement',
|
2021-02-22 21:40:15 +01:00
|
|
|
// 'addAttributesToSVGElement',
|
|
|
|
// 'removeOffCanvasPaths',
|
|
|
|
// 'reusePaths',
|
|
|
|
];
|
2021-01-10 19:11:22 +01:00
|
|
|
|
|
|
|
const svgc = require("./src/svgclean.js");
|
2021-01-13 11:40:33 +01:00
|
|
|
const inst = svgc.configure({plugins});
|
2021-01-10 19:11:22 +01:00
|
|
|
|
|
|
|
exports.optimize = function(data) {
|
|
|
|
return svgc.optimize(inst, data)
|
|
|
|
.then((result) => result.data);
|
|
|
|
};
|