build: Update 'svgo' to latest v2.8.0 & re-crush images

Updating 'svgo' to v2.8.0 and newest Wikimedia SVG guidelines –
mainly around new whitespace features of SVGO.

Change-Id: Ie48f5e78b3f9b6e7f01b65618c1d6089fa4a2f54
This commit is contained in:
Volker E 2022-02-27 03:34:24 -08:00 committed by Krinkle
parent f8560e27ac
commit f2d7158616
6 changed files with 57 additions and 191 deletions

View File

@ -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
};

161
package-lock.json generated
View File

@ -28,7 +28,7 @@
"node-fetch": "2.6.1",
"pre-commit": "1.2.2",
"stylelint-config-wikimedia": "0.11.1",
"svgo": "2.3.1",
"svgo": "2.8.0",
"typescript": "4.5.5",
"vue": "2.6.11",
"vue-jest": "3.0.7"
@ -3132,9 +3132,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"
@ -22243,17 +22243,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": {
@ -22263,55 +22263,6 @@
"node": ">=10.13.0"
}
},
"node_modules/svgo/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/svgo/node_modules/chalk": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/svgo/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/svgo/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/svgo/node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
@ -22413,15 +22364,6 @@
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/svgo/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/svgo/node_modules/nth-check": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
@ -22434,18 +22376,6 @@
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
"node_modules/svgo/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@ -27097,9 +27027,9 @@
"dev": true
},
"@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/anymatch": {
@ -42386,54 +42316,20 @@
"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"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
@ -42502,12 +42398,6 @@
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==",
"dev": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"nth-check": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
@ -42516,15 +42406,6 @@
"requires": {
"boolbase": "^1.0.0"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},

View File

@ -12,7 +12,7 @@
"lint:i18n": "banana-checker --requireLowerCase=0 i18n/",
"doc": "jsdoc -c jsdoc.json && npm run build-storybook -s resources/skins.vector.styles",
"build-storybook": "bash dev-scripts/setup-storybook.sh && build-storybook --quiet --loglevel warn -o docs/ui",
"minify-svg": "svgo --config=.svgo.config.js -q -r -f resources/",
"minify-svg": "svgo --config=.svgo.config.js --quiet --recursive --folder resources/",
"pre-commit": "[ \"${PRE_COMMIT:-1}\" -eq 0 ] || npm -s t"
},
"pre-commit": "pre-commit",
@ -40,7 +40,7 @@
"node-fetch": "2.6.1",
"pre-commit": "1.2.2",
"stylelint-config-wikimedia": "0.11.1",
"svgo": "2.3.1",
"svgo": "2.8.0",
"typescript": "4.5.5",
"vue": "2.6.11",
"vue-jest": "3.0.7"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12">
<path fill="#ffffff" d="m11.05 3.996-.965-1.053-4.035 3.86-3.947-3.86L1.05 3.996l5 5 5-5"/>
<path fill="#fff" d="m11.05 3.996-.965-1.053-4.035 3.86-3.947-3.86L1.05 3.996l5 5 5-5"/>
</svg>

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 220 B

View File

@ -6,7 +6,7 @@
<stop offset=".5" stop-color="#68bdff"/>
<stop offset="1" stop-color="#fff"/>
</linearGradient>
<linearGradient id="b" x1="13.47" x2="4.596" y1="14.363" y2="3.397" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
<linearGradient xlink:href="#a" id="b" x1="13.47" x2="4.596" y1="14.363" y2="3.397" gradientUnits="userSpaceOnUse"/>
</defs>
<path fill="url(#b)" stroke="#c8b250" d="m8.103 1.146 2.175 4.408 4.864.707-3.52 3.431.831 4.845-4.351-2.287-4.351 2.287.831-4.845-3.52-3.431 4.864-.707z"/>
</svg>

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

View File

@ -9,7 +9,7 @@
<stop offset=".5" stop-color="#68bdff"/>
<stop offset="1" stop-color="#fff"/>
</linearGradient>
<linearGradient id="b" x1="13.5" x2="4.6" y1="14.4" y2="3.4" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
<linearGradient xlink:href="#a" id="b" x1="13.5" x2="4.6" y1="14.4" y2="3.4" gradientUnits="userSpaceOnUse"/>
</defs>
<path fill="url(#b)" stroke="#7cb5d1" d="m8.1 1.1 2.2 4.5 4.8.7-3.5 3.4.9 4.8L8 12.2l-4.3 2.3.8-4.8L1 6.3l4.8-.7z"/>
</svg>

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 602 B