mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 12:08:28 +02:00
🎉 Add svgclean (svgo graalvm/browser ready fork).
This commit is contained in:
parent
16469daff3
commit
c648add963
71 changed files with 15135 additions and 0 deletions
101
vendor/svgclean/examples/test.js
vendored
Normal file
101
vendor/svgclean/examples/test.js
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
'use strict';
|
||||
|
||||
var FS = require('fs'),
|
||||
PATH = require('path'),
|
||||
SVGO = require('../lib/svgo'),
|
||||
filepath = PATH.resolve(__dirname, 'test.svg'),
|
||||
svgo = new SVGO({
|
||||
plugins: [{
|
||||
cleanupAttrs: true,
|
||||
}, {
|
||||
removeDoctype: true,
|
||||
},{
|
||||
removeXMLProcInst: true,
|
||||
},{
|
||||
removeComments: true,
|
||||
},{
|
||||
removeMetadata: true,
|
||||
},{
|
||||
removeTitle: true,
|
||||
},{
|
||||
removeDesc: true,
|
||||
},{
|
||||
removeUselessDefs: true,
|
||||
},{
|
||||
removeEditorsNSData: true,
|
||||
},{
|
||||
removeEmptyAttrs: true,
|
||||
},{
|
||||
removeHiddenElems: true,
|
||||
},{
|
||||
removeEmptyText: true,
|
||||
},{
|
||||
removeEmptyContainers: true,
|
||||
},{
|
||||
removeViewBox: false,
|
||||
},{
|
||||
cleanupEnableBackground: true,
|
||||
},{
|
||||
convertStyleToAttrs: true,
|
||||
},{
|
||||
convertColors: true,
|
||||
},{
|
||||
convertPathData: true,
|
||||
},{
|
||||
convertTransform: true,
|
||||
},{
|
||||
removeUnknownsAndDefaults: true,
|
||||
},{
|
||||
removeNonInheritableGroupAttrs: true,
|
||||
},{
|
||||
removeUselessStrokeAndFill: true,
|
||||
},{
|
||||
removeUnusedNS: true,
|
||||
},{
|
||||
cleanupIDs: true,
|
||||
},{
|
||||
cleanupNumericValues: true,
|
||||
},{
|
||||
moveElemsAttrsToGroup: true,
|
||||
},{
|
||||
moveGroupAttrsToElems: true,
|
||||
},{
|
||||
collapseGroups: true,
|
||||
},{
|
||||
removeRasterImages: false,
|
||||
},{
|
||||
mergePaths: true,
|
||||
},{
|
||||
convertShapeToPath: true,
|
||||
},{
|
||||
sortAttrs: true,
|
||||
},{
|
||||
removeDimensions: true,
|
||||
},{
|
||||
removeAttrs: {attrs: '(stroke|fill)'},
|
||||
}]
|
||||
});
|
||||
|
||||
FS.readFile(filepath, 'utf8', function(err, data) {
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
svgo.optimize(data, {path: filepath}).then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
|
||||
// {
|
||||
// // optimized SVG data string
|
||||
// data: '<svg width="10" height="20">test</svg>'
|
||||
// // additional info such as width/height
|
||||
// info: {
|
||||
// width: '10',
|
||||
// height: '20'
|
||||
// }
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue