From 820a71a3764551e4c003d95205302b2dca67baea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Mon, 29 Nov 2021 18:59:11 +0100 Subject: [PATCH] Update SVGO configuration (#6926) --- svgo.config.js | 181 +++++++++++++++++++++++++------------------------ 1 file changed, 91 insertions(+), 90 deletions(-) diff --git a/svgo.config.js b/svgo.config.js index 98a08c733..ca5bc4f65 100644 --- a/svgo.config.js +++ b/svgo.config.js @@ -1,99 +1,100 @@ module.exports = { multipass: true, + eol: 'lf', plugins: [ + 'cleanupAttrs', + 'inlineStyles', + 'removeDoctype', + 'removeXMLProcInst', + 'removeComments', + 'removeMetadata', + 'removeDesc', + 'removeUselessDefs', + 'removeEditorsNSData', + 'removeEmptyAttrs', + 'removeHiddenElems', + 'removeEmptyText', + 'removeEmptyContainers', + 'cleanupEnableBackground', { - name: 'preset-default', + name: 'convertPathData', params: { - overrides: { - // customize options - convertPathData: { - // 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 tag - sortAttrs: { - order: ['role', 'viewBox'], - xmlnsOrder: 'end', - }, - - // Convert basic shapes (such as ) to - convertShapeToPath: { - // including - convertArcs: true, - }, - - // Compound all s into one - mergePaths: { - force: true, - noSpaceAfterFlags: false, - }, - - // Keep the tag - removeTitle: false, - - // Keep the role="img" attribute and automatically add it - // to the tag if it's not there already - addAttributesToSVGElement: { - attributes: [{ role: 'img' }], - }, - - // Keep the 'role' attribute, if it's already defined - removeUnknownsAndDefaults: { - keepRoleAttr: true, - }, - - // Remove all attributes except 'role', 'viewBox', and 'xmlns' from - // tags - removeAttrs: { - attrs: ['baseProfile', 'version', 'fill-rule'], - }, - - // Remove paths with fill="none" - removeUselessStrokeAndFill: { - removeNone: true, - }, - - // Explicitly enable everything else - removeDoctype: true, - removeXMLProcInst: true, - removeComments: true, - removeMetadata: true, - removeEditorsNSData: true, - cleanupAttrs: true, - inlineStyles: true, - minifyStyles: true, - convertStyleToAttrs: true, - cleanupIDs: true, - prefixIds: true, - removeRasterImages: true, - removeUselessDefs: true, - cleanupNumericValues: true, - cleanupListOfValues: true, - convertColors: true, - removeNonInheritableGroupAttrs: true, - removeViewBox: true, - cleanupEnableBackground: true, - removeHiddenElems: true, - removeEmptyText: true, - moveElemsAttrsToGroup: true, - moveGroupAttrsToElems: true, - collapseGroups: true, - convertTransform: true, - removeEmptyAttrs: true, - removeEmptyContainers: true, - removeUnusedNS: true, - removeDesc: true, - removeDimensions: true, - removeStyleElement: true, - removeScriptElement: true, - removeOffCanvasPaths: true, - reusePaths: true, - }, + // 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', + 'cleanupIDs', + 'cleanupNumericValues', + 'cleanupListOfValues', + 'moveGroupAttrsToElems', + 'collapseGroups', + 'removeRasterImages', + { + // Compound all s into one + name: 'mergePaths', + params: { + force: true, + noSpaceAfterFlags: false, + }, + }, + { + // Convert basic shapes (such as ) to + name: 'convertShapeToPath', + params: { + // including + convertArcs: true, + }, + }, + 'convertEllipseToCircle', + { + // Sort the attributes on the tag + name: 'sortAttrs', + params: { + order: ['role', 'viewBox'], + xmlnsOrder: 'end', + }, + }, + 'sortDefsChildren', + 'removeDimensions', + { + name: 'removeAttrs', + params: { + attrs: ['svg:(?!(role|viewBox|xmlns))', 'path:(?!d)', 'title:*'], + }, + }, + 'removeElementsByAttr', + { + // Keep the role="img" attribute and automatically add it + // to the tag if it's not there already + name: 'addAttributesToSVGElement', + params: { + attributes: [{ role: 'img', xmlns: 'http://www.w3.org/2000/svg' }], + }, + }, + 'removeOffCanvasPaths', + 'removeStyleElement', + 'removeScriptElement', + 'reusePaths', ], };