1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-26 01:13:41 +02:00
simple-icons/svgo.config.js
Álvaro Mondéjar b3360c3a0b
Upgrade SVGO to version 2 (#5079)
* Upgrade SVGO to version 2

* Sketch neither supports space after arc flags

* Bump svgo to version 2.0.3 and enable 'reusePaths'

* Improve comment

* Simplify additional plugins list; update svgo script in package.json

* Apply suggestions from review
2021-02-21 13:48:30 +01:00

127 lines
2.7 KiB
JavaScript

const { extendDefaultPlugins } = require('svgo');
module.exports = {
multipass: true,
plugins: extendDefaultPlugins([
{
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,
},
},
// Sort the attributes on the <svg> tag
{
name: 'sortAttrs',
params: {
order: ['role', 'viewBox'],
xmlnsOrder: 'end',
},
},
// Convert basic shapes (such as <circle>) to <path>
{
name: 'convertShapeToPath',
params: {
// including <arc>
convertArcs: true,
},
},
// Compound all <path>s into one
{
name: 'mergePaths',
params: {
force: true,
noSpaceAfterFlags: false,
},
},
// Keep the <title> tag
{
name: 'removeTitle',
active: false,
},
// 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'},
],
},
},
// Keep the 'role' attribute, if it's already defined
{
name: 'removeUnknownsAndDefaults',
params: {
keepRoleAttr: true,
},
},
// Remove all attributes except 'role', 'viewBox', and 'xmlns' from
// <svg> tags
{
name: 'removeAttrs',
params: {
attrs: [
'baseProfile',
'version',
'fill-rule',
],
},
},
// Remove paths with fill="none"
{
name: 'removeUselessStrokeAndFill',
params: {
removeNone: true,
},
},
// Explicitly enable everything else
'removeDoctype',
'removeXMLProcInst',
'removeComments',
'removeMetadata',
'removeEditorsNSData',
'cleanupAttrs',
'inlineStyles',
'minifyStyles',
'convertStyleToAttrs',
'cleanupIDs',
'prefixIds',
'removeRasterImages',
'removeUselessDefs',
'cleanupNumericValues',
'cleanupListOfValues',
'convertColors',
'removeNonInheritableGroupAttrs',
'removeViewBox',
'cleanupEnableBackground',
'removeHiddenElems',
'removeEmptyText',
'moveElemsAttrsToGroup',
'moveGroupAttrsToElems',
'collapseGroups',
'convertTransform',
'removeEmptyAttrs',
'removeEmptyContainers',
'removeUnusedNS',
'removeDesc',
'removeDimensions',
'removeStyleElement',
'removeScriptElement',
'removeOffCanvasPaths',
'reusePaths',
]),
};