-
Notifications
You must be signed in to change notification settings - Fork 1
/
svgo.config.min.mjs
71 lines (71 loc) · 1.62 KB
/
svgo.config.min.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var prefixId = 0
export default {
multipass: true,
eol: 'lf',
plugins: [
'cleanupAttrs',
'inlineStyles',
'removeXlink',
'removeDoctype',
'removeXMLProcInst',
'removeComments',
'removeMetadata',
'removeDesc',
'removeUselessDefs',
'removeEditorsNSData',
'removeEmptyAttrs',
'removeHiddenElems',
'removeEmptyText',
'removeEmptyContainers',
'cleanupEnableBackground',
'removeUnusedNS',
'cleanupNumericValues',
'cleanupListOfValues',
'moveGroupAttrsToElems',
'collapseGroups',
{
// Sort the attributes on the <svg> tag
name: 'sortAttrs',
params: {
order: ['role', 'viewBox'],
xmlnsOrder: 'end',
},
},
'sortDefsChildren',
// 'removeDimensions',
'removeElementsByAttr',
{
// Keep the role="img" attribute and automatically add it
// to the <svg> tag if it's not there already
name: 'addAttributesToSVGElement',
params: {
attributes: [{ role: 'img', xmlns: 'http://www.w3.org/2000/svg' }],
},
},
'removeOffCanvasPaths',
{
name: "addAttributesToSVGElement",
params: {
attributes: [{
width: "32",
height: "32",
}]
},
},
{
name: 'prefixIds',
params: {
prefix: function (node, b) {
console.log(node.attributes.id, b.path)
if (node.attributes.id !== undefined && node.attributes.id.indexOf(b.path) == -1) {
return b.path + prefixId++
}
else {
return prefixId++
}
}
}
},
// 'reusePaths',
],
};