From 5abe9869536f2f7ccc92746219955f009aa1450a Mon Sep 17 00:00:00 2001 From: Volker E Date: Sun, 27 Feb 2022 03:08:40 -0800 Subject: [PATCH] build: Update 'svgo' to latest v2.8.0 & re-crush images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating 'svgo' to v2.8.0 and newest Wikimedia SVG guidelines – mainly around new whitespace features of SVGO. Change-Id: I7c9eb84fdaeb50f6ff04c9e5cd2f005e129d555a --- .svgo.config.js | 77 +++++++++++++-------------------- package-lock.json | 42 +++++++++--------- package.json | 4 +- resources/images/cog-sprite.svg | 4 +- 4 files changed, 56 insertions(+), 71 deletions(-) diff --git a/.svgo.config.js b/.svgo.config.js index e2abffbd..492f6874 100644 --- a/.svgo.config.js +++ b/.svgo.config.js @@ -1,55 +1,40 @@ /** * SVGO Configuration + * Compatible to v2.4.0+ * Recommended options from: * https://www.mediawiki.org/wiki/Manual:Coding_conventions/SVG#Exemplified_safe_configuration */ -const { extendDefaultPlugins } = require( 'svgo' ); module.exports = { - multipass: true, - plugins: extendDefaultPlugins( [ + plugins: [ { - name: 'cleanupIDs', - active: false + // Set of built-in plugins enabled by default. + name: 'preset-default', + params: { + overrides: { + cleanupIDs: false, + removeDesc: false, + removeTitle: false, + removeViewBox: false, + // If the SVG doesn't start with an XML declaration, then its MIME type will + // be detected as "text/plain" rather than "image/svg+xml" by libmagic and, + // consequently, MediaWiki's CSSMin CSS minifier. libmagic's default database + // currently requires that SVGs contain an XML declaration: + // https://github.com/threatstack/libmagic/blob/master/magic/Magdir/sgml#L5 + removeXMLProcInst: false + } + } }, - { - name: 'removeDesc', - active: false - }, - { - name: 'removeRasterImages', - active: true - }, - { - name: 'removeTitle', - active: false - }, - { - name: 'removeViewBox', - active: false - }, - { - // If the SVG doesn't start with an XML declaration, then its MIME type will - // be detected as "text/plain" rather than "image/svg+xml" by libmagic and, - // consequently, MediaWiki's CSSMin CSS minifier. libmagic's default database - // currently requires that SVGs contain an XML declaration: - // https://github.com/threatstack/libmagic/blob/master/magic/Magdir/sgml#L5 - name: 'removeXMLProcInst', - active: false - }, - { - name: 'sortAttrs', - active: true - } - ] ), - - // 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 - // - // Unfortunately EOL cannot be configured, SVGO uses the platform's EOL marker. - // On non-unix systems the linebreaks will be normalized to LF (unix) only at git commit, - // assuming `core.autocrlf` is 'true' (default) or 'input'. + 'removeRasterImages', + 'sortAttrs' + ], + // Set whitespace according to Wikimedia Coding Conventions. + // @see https://github.com/svg/svgo/blob/v2.8.0/lib/stringifier.js#L41 for available options. js2svg: { - indent: "\t", - pretty: true, - } -} + eol: 'lf', + finalNewline: true, + // Configure the indent to tabs (default 4 spaces) used by `--pretty` here. + indent: '\t', + pretty: true + }, + multipass: true +}; diff --git a/package-lock.json b/package-lock.json index 0fed2790..8f1fd79b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "grunt-stylelint": "0.17.0", "postcss-less": "6.0.0", "stylelint-config-wikimedia": "0.11.1", - "svgo": "2.3.1" + "svgo": "2.8.0" } }, "node_modules/@babel/code-frame": { @@ -475,9 +475,9 @@ } }, "node_modules/@trysound/sax": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.1.1.tgz", - "integrity": "sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", + "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", "dev": true, "engines": { "node": ">=10.13.0" @@ -5343,17 +5343,17 @@ "dev": true }, "node_modules/svgo": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.3.1.tgz", - "integrity": "sha512-riDDIQgXpEnn0BEl9Gvhh1LNLIyiusSpt64IR8upJu7MwxnzetmF/Y57pXQD2NMX2lVyMRzXt5f2M5rO4wG7Dw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz", + "integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==", "dev": true, "dependencies": { - "@trysound/sax": "0.1.1", - "chalk": "^4.1.0", - "commander": "^7.1.0", + "@trysound/sax": "0.2.0", + "commander": "^7.2.0", "css-select": "^4.1.3", - "css-tree": "^1.1.2", + "css-tree": "^1.1.3", "csso": "^4.2.0", + "picocolors": "^1.0.0", "stable": "^0.1.8" }, "bin": { @@ -6240,9 +6240,9 @@ } }, "@trysound/sax": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.1.1.tgz", - "integrity": "sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", + "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", "dev": true }, "@types/mdast": { @@ -9936,17 +9936,17 @@ "dev": true }, "svgo": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.3.1.tgz", - "integrity": "sha512-riDDIQgXpEnn0BEl9Gvhh1LNLIyiusSpt64IR8upJu7MwxnzetmF/Y57pXQD2NMX2lVyMRzXt5f2M5rO4wG7Dw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz", + "integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==", "dev": true, "requires": { - "@trysound/sax": "0.1.1", - "chalk": "^4.1.0", - "commander": "^7.1.0", + "@trysound/sax": "0.2.0", + "commander": "^7.2.0", "css-select": "^4.1.3", - "css-tree": "^1.1.2", + "css-tree": "^1.1.3", "csso": "^4.2.0", + "picocolors": "^1.0.0", "stable": "^0.1.8" } }, diff --git a/package.json b/package.json index e78e16e6..116de879 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "minify-svg": "svgo --config=.svgo.config.js -q -r -f resources/images/", + "minify-svg": "svgo --config=.svgo.config.js --quiet --recursive --folder resources/images/", "test": "grunt test" }, "devDependencies": { @@ -12,7 +12,7 @@ "grunt-stylelint": "0.17.0", "postcss-less": "6.0.0", "stylelint-config-wikimedia": "0.11.1", - "svgo": "2.3.1" + "svgo": "2.8.0" }, "eslintIgnore": [ "lib/**", diff --git a/resources/images/cog-sprite.svg b/resources/images/cog-sprite.svg index 28621287..aee7abfb 100644 --- a/resources/images/cog-sprite.svg +++ b/resources/images/cog-sprite.svg @@ -3,6 +3,6 @@ - - + +