build: Update 'svgo' to latest v2.8.0

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

Change-Id: I4a9b0efb9fe8d4648a4d218397cf3d9548552421
isekai
Volker E 3 years ago
parent e4c58084bf
commit 91c3bb0f61

@ -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/main/lib/svgo/coa.js#L194 for more config 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
};

6342
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -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": {
@ -11,6 +11,6 @@
"grunt-eslint": "23.0.0",
"grunt-stylelint": "0.16.0",
"stylelint-config-wikimedia": "0.11.1",
"svgo": "2.3.1"
"svgo": "2.8.0"
}
}

Loading…
Cancel
Save