diff --git a/package-lock.json b/package-lock.json index 7e4f20bce..b24aa5d98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4024,13 +4024,13 @@ } }, "svgo": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.3.1.tgz", - "integrity": "sha512-riDDIQgXpEnn0BEl9Gvhh1LNLIyiusSpt64IR8upJu7MwxnzetmF/Y57pXQD2NMX2lVyMRzXt5f2M5rO4wG7Dw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.4.0.tgz", + "integrity": "sha512-W25S1UUm9Lm9VnE0TvCzL7aso/NCzDEaXLaElCUO/KaVitw0+IBicSVfM1L1c0YHK5TOFh73yQ2naCpVHEQ/OQ==", "dev": true, "requires": { "@trysound/sax": "0.1.1", - "chalk": "^4.1.0", + "colorette": "^1.2.2", "commander": "^7.1.0", "css-select": "^4.1.3", "css-tree": "^1.1.2", @@ -4175,9 +4175,9 @@ } }, "uglify-js": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.0.tgz", - "integrity": "sha512-R/tiGB1ZXp2BC+TkRGLwj8xUZgdfT2f4UZEgX6aVjJ5uttPrr4fYmwTWDGqVnBCLbOXRMY6nr/BTbwCtVfps0g==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", + "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index a339c1275..cb22c02ac 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,9 @@ "svg-path-bbox": "1.0.1", "svg-path-segments": "1.0.0", "svglint": "1.0.8", - "svgo": "2.3.1", + "svgo": "2.4.0", "svgpath": "2.3.1", - "uglify-js": "3.14.0" + "uglify-js": "3.14.1" }, "scripts": { "build": "node scripts/build/package.js", diff --git a/svgo.config.js b/svgo.config.js index 4815748fc..062d00b19 100644 --- a/svgo.config.js +++ b/svgo.config.js @@ -1,126 +1,105 @@ -const { extendDefaultPlugins } = require('svgo'); - module.exports = { multipass: true, - plugins: extendDefaultPlugins([ + plugins: [ { - name: 'convertPathData', + name: 'preset-default', 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, + 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, + }, }, }, - - // Sort the attributes on the tag - { - name: 'sortAttrs', - params: { - order: ['role', 'viewBox'], - xmlnsOrder: 'end', - }, - }, - - // Convert basic shapes (such as ) to - { - name: 'convertShapeToPath', - params: { - // including - convertArcs: true, - }, - }, - - // Compound all s into one - { - name: 'mergePaths', - params: { - force: true, - noSpaceAfterFlags: false, - }, - }, - - // Keep the tag - { - name: 'removeTitle', - active: false, - }, - - // Keep the role="img" attribute and automatically add it - // to the 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 - // 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', - ]), + ], };