0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-04 13:29:14 -05:00
penpot/vendor/svgclean/main.js

80 lines
2 KiB
JavaScript
Raw Normal View History

/*
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},
{convertPathData: {
lineShorthands: false,
curveSmoothShorthands: false,
forceAbsolutePath: true,
}}
];
*/
const plugins = [
2021-02-25 09:41:57 +01:00
// 'removeDoctype',
// 'removeXMLProcInst',
// 'removeComments',
// 'removeMetadata',
// 'removeXMLNS',
2021-02-25 09:41:57 +01:00
// 'removeEditorsNSData',
// 'cleanupAttrs',
// 'inlineStyles',
// 'minifyStyles',
// 'convertStyleToAttrs'
2021-02-23 10:11:43 +01:00
// 'cleanupIDs',
// 'prefixIds',
// 'removeRasterImages',
// 'removeUselessDefs',
2021-02-25 09:41:57 +01:00
// 'cleanupNumericValues',
// 'cleanupListOfValues',
2021-02-25 09:41:57 +01:00
// 'convertColors',
// 'removeUnknownsAndDefaults',
// 'removeNonInheritableGroupAttrs',
// 'removeUselessStrokeAndFill',
// 'removeViewBox',
2021-02-25 09:41:57 +01:00
// 'cleanupEnableBackground',
// 'removeHiddenElems',
// 'removeEmptyText',
// 'convertShapeToPath',
// 'convertEllipseToCircle',
// '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',
// 'sortAttrs',
2021-02-25 09:41:57 +01:00
// 'sortDefsChildren',
// 'removeTitle',
// 'removeDesc',
// 'removeDimensions',
// 'removeAttrs',
// 'removeAttributesBySelector',
// 'removeElementsByAttr',
// 'addClassesToSVGElement',
2021-02-25 09:41:57 +01:00
// 'removeStyleElement',
// 'removeScriptElement',
// 'addAttributesToSVGElement',
// 'removeOffCanvasPaths',
// 'reusePaths',
];
const svgc = require("./src/svgclean.js");
const inst = svgc.configure({plugins});
exports.optimize = function(data) {
return svgc.optimize(inst, data)
.then((result) => result.data);
};