-
Notifications
You must be signed in to change notification settings - Fork 1
/
svgo.config.mjs
129 lines (129 loc) · 2.94 KB
/
svgo.config.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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',
{
name: 'convertPathData',
params: {
// 3 decimals of precision in floating point numbers
floatPrecision: 3,
// Some editors (e.g. Adobe Illustrator and Sketch) cannot parse flags
// without space wrapping
noSpaceAfterFlags: false,
},
},
'convertTransform',
{
name: 'removeUnknownsAndDefaults',
params: {
// Keep the 'role' attribute, if it's already defined
keepRoleAttr: true,
},
},
'removeNonInheritableGroupAttrs',
{
// Remove paths with fill="none"
name: 'removeUselessStrokeAndFill',
params: {
removeNone: true,
},
},
'removeUselessStrokeAndFill',
'removeUnusedNS',
'cleanupNumericValues',
'cleanupListOfValues',
'moveGroupAttrsToElems',
'collapseGroups',
// 'removeRasterImages',
{
// Compound all <path>s into one
name: 'mergePaths',
params: {
force: true,
noSpaceAfterFlags: false,
},
},
{
// Convert basic shapes (such as <circle>) to <path>
name: 'convertShapeToPath',
params: {
// including <arc>
convertArcs: true,
},
},
'convertEllipseToCircle',
{
// Sort the attributes on the <svg> tag
name: 'sortAttrs',
params: {
order: ['role', 'viewBox'],
xmlnsOrder: 'end',
},
},
'sortDefsChildren',
// 'removeDimensions',
{
name: 'removeAttrs',
params: {
attrs: [
'svg:(?!(role|xmlns))',
'path:(?!d)',
'title:*',
'svg:xmlns.xlink',
'path:fill:black',
'path:fill:rgba(0,0,0,0)',
'path:fill:rgb\\(0%, 0%, 0%\\)',
'path:fill:"rgb\\(0%, 0%, 0%\\)"',
'path:fill:#000000',
],
},
},
'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',
'removeStyleElement',
'removeScriptElement',
{
name: "addAttributesToSVGElement",
params: {
attributes: [{
width: "32",
height: "32",
}]
},
},
{
name: 'prefixIds',
params: {
prefix: function (a, b) {
console.log(a, b)
return prefixId++
}
}
},
// 'reusePaths',
],
};