-
-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SVGO v2 config. Drop SVGO v1 support!
BREAKING CHANGE! This commit provides the new config file for svgo 2.0.0+ and removes the config file for svgo 1.3.2 and lower. To continue use tools in the project, please upgrade svgo to the latest version: npm install -g svgo
- Loading branch information
Showing
4 changed files
with
119 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
module.exports = { | ||
multipass: true, | ||
plugins: [ | ||
// remove DOCTYPE declaration | ||
'removeDoctype', | ||
// remove XML processing instructions | ||
'removeXMLProcInst', | ||
// remove comments | ||
'removeComments', | ||
// remove <metadata> | ||
'removeMetadata', | ||
// remove editors namespaces, elements and attributes | ||
'removeEditorsNSData', | ||
// cleanup attributes values from newlines, trailing and repeating spaces | ||
'cleanupAttrs', | ||
/** | ||
* { | ||
* // remove unused IDs | ||
* name: 'cleanupIDs', | ||
* params: { | ||
* minify: false, | ||
* preserve: ['current-color-scheme'] | ||
* } | ||
* }, | ||
*/ | ||
// remove raster images references in <image> | ||
'removeRasterImages', | ||
// remove elements in <defs> without id | ||
'removeUselessDefs', | ||
{ | ||
// round numeric values to the fixed precision | ||
// remove default 'px' units | ||
// y="749.936002px" --> y="749.936" | ||
name: 'cleanupNumericValues', | ||
params: { convertToPx: false } | ||
}, | ||
{ | ||
// round list of values to the fixed precision | ||
// viewBox="0 0 16px 16px" --> viewBox="0 0 16 16" | ||
name: 'cleanupListOfValues', | ||
params: { | ||
floatPrecision: 2, | ||
leadingZero: true, | ||
defaultPx: true, | ||
convertToPx: false, | ||
} | ||
}, | ||
{ | ||
// convert different colors formats to #rrggbb | ||
name: 'convertColors', | ||
params: { | ||
shorthex: false, | ||
shortname: false, | ||
} | ||
}, | ||
/** | ||
* { | ||
* // remove unknown elements content and attributes | ||
* // don't touch attributes with default values | ||
* name: 'removeUnknownsAndDefaults', | ||
* params: { defaultAttrs: false } | ||
* }, | ||
*/ | ||
// remove viewBox attr which coincides with a width/height box | ||
'removeViewBox', | ||
// remove or cleanup enable-background attribute when possible | ||
'cleanupEnableBackground', | ||
{ | ||
// remove hidden elements (zero sized, with absent attributes) | ||
name: 'removeHiddenElems', | ||
params: { opacity0: false } | ||
}, | ||
// remove empty <text/>, <tspan/>, and <tref xlink:href=""/> elements | ||
'removeEmptyText', | ||
// convert non-eccentric <ellipse> to <circle> | ||
'convertEllipseToCircle', | ||
// remove attributes with empty values | ||
'removeEmptyAttrs', | ||
// remove empty containers | ||
'removeEmptyContainers', | ||
// remove unused namespaces declaration | ||
'removeUnusedNS', | ||
{ | ||
// sort element attributes for epic readability | ||
name: 'sortAttrs', | ||
params: { | ||
order: [ | ||
'id', | ||
'fill', 'stroke', 'opacity', | ||
'style', 'class', | ||
'width', 'height', | ||
'x', 'x1', 'x2', | ||
'y', 'y1', 'y2', | ||
'cx', 'cy', | ||
'rx', 'ry', 'r', | ||
'transform', | ||
'marker', | ||
'points', | ||
'd', | ||
] | ||
} | ||
}, | ||
// remove <title> | ||
'removeTitle', | ||
// remove <desc> | ||
'removeDesc', | ||
// remove elements that are drawn outside of the viewbox | ||
// 'removeOffCanvasPaths', | ||
], | ||
|
||
// configure the indent (default 4 spaces) used by `--pretty` here: | ||
// @see https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options | ||
js2svg: { | ||
pretty: true, | ||
indent: 1 | ||
} | ||
} |