build: Update SVGO to latest v2.3.0 and re-optimize SVGs
SVGO v2.x changed configuration to JS, amending configuration. Adding new 'minify-svg' npm script. Also re-optimize SVGs. Bug: T278656 Change-Id: I88ebed650be0d20b71bca6f15f3aa70b6b5eb42a
55
.svgo.config.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* SVGO Configuration
|
||||
* 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( [
|
||||
{
|
||||
name: 'cleanupIDs',
|
||||
active: 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'.
|
||||
js2svg: {
|
||||
indent: "\t",
|
||||
pretty: true,
|
||||
}
|
||||
}
|
||||
42
Gruntfile.js
@@ -5,7 +5,6 @@ module.exports = function ( grunt ) {
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
grunt.loadNpmTasks( 'grunt-eslint' );
|
||||
grunt.loadNpmTasks( 'grunt-stylelint' );
|
||||
grunt.loadNpmTasks( 'grunt-svgmin' );
|
||||
|
||||
grunt.initConfig( {
|
||||
eslint: {
|
||||
@@ -29,46 +28,9 @@ module.exports = function ( grunt ) {
|
||||
'!vendor/**'
|
||||
]
|
||||
},
|
||||
banana: conf.MessagesDirs,
|
||||
// SVG Optimization
|
||||
svgmin: {
|
||||
options: {
|
||||
js2svg: {
|
||||
indent: '\t',
|
||||
pretty: true
|
||||
},
|
||||
multipass: true,
|
||||
plugins: [ {
|
||||
cleanupIDs: false
|
||||
}, {
|
||||
removeDesc: false
|
||||
}, {
|
||||
removeRasterImages: true
|
||||
}, {
|
||||
removeTitle: false
|
||||
}, {
|
||||
removeViewBox: false
|
||||
}, {
|
||||
removeXMLProcInst: false
|
||||
}, {
|
||||
sortAttrs: true
|
||||
} ]
|
||||
},
|
||||
all: {
|
||||
files: [ {
|
||||
expand: true,
|
||||
cwd: 'resources/images',
|
||||
src: [
|
||||
'**/*.svg'
|
||||
],
|
||||
dest: 'resources/images/',
|
||||
ext: '.svg'
|
||||
} ]
|
||||
}
|
||||
}
|
||||
banana: conf.MessagesDirs
|
||||
} );
|
||||
|
||||
grunt.registerTask( 'minify', 'svgmin' );
|
||||
grunt.registerTask( 'test', [ 'eslint', 'stylelint', 'banana' ] );
|
||||
grunt.registerTask( 'default', [ 'minify', 'test' ] );
|
||||
grunt.registerTask( 'default', [ 'test' ] );
|
||||
};
|
||||
|
||||
2303
package-lock.json
generated
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"minify-svg": "svgo --config=.svgo.config.js -q -r -f resources/images/",
|
||||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -9,8 +10,8 @@
|
||||
"grunt-banana-checker": "0.9.0",
|
||||
"grunt-eslint": "23.0.0",
|
||||
"grunt-stylelint": "0.16.0",
|
||||
"grunt-svgmin": "5.0.0",
|
||||
"stylelint-config-wikimedia": "0.10.3"
|
||||
"stylelint-config-wikimedia": "0.10.3",
|
||||
"svgo": "2.3.0"
|
||||
},
|
||||
"eslintIgnore": [
|
||||
"lib/**",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="#54595d" d="M7 13.1l8.9 8.9c.8-.8.8-2 0-2.8l-6.1-6.1 6-6.1c.8-.8.8-2 0-2.8L7 13.1z"/>
|
||||
<path fill="#54595d" d="m7 13.1 8.9 8.9c.8-.8.8-2 0-2.8l-6.1-6.1 6-6.1c.8-.8.8-2 0-2.8L7 13.1z"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||
<path d="M3.636 2.222l14.142 14.142-1.414 1.414L2.222 3.636z"/>
|
||||
<path d="M17.778 3.636L3.636 17.778l-1.414-1.414L16.364 2.222z"/>
|
||||
<path d="m3.636 2.222 14.142 14.142-1.414 1.414L2.222 3.636z"/>
|
||||
<path d="M17.778 3.636 3.636 17.778l-1.414-1.414L16.364 2.222z"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
@@ -3,5 +3,5 @@
|
||||
<title>
|
||||
language
|
||||
</title>
|
||||
<path fill="#54595d" d="M20 18h-1.44a.61.61 0 01-.4-.12.81.81 0 01-.23-.31L17 15h-5l-1 2.54a.77.77 0 01-.22.3.59.59 0 01-.4.14H9l4.55-11.47h1.89zm-3.53-4.31L14.89 9.5a11.62 11.62 0 01-.39-1.24q-.09.37-.19.69l-.19.56-1.58 4.19zm-6.3-1.58a13.43 13.43 0 01-2.91-1.41 11.46 11.46 0 002.81-5.37H12V4H7.31a4 4 0 00-.2-.56C6.87 2.79 6.6 2 6.6 2l-1.47.5s.4.89.6 1.5H0v1.33h2.15A11.23 11.23 0 005 10.7a17.19 17.19 0 01-5 2.1q.56.82.87 1.38a23.28 23.28 0 005.22-2.51 15.64 15.64 0 003.56 1.77zM3.63 5.33h4.91a8.11 8.11 0 01-2.45 4.45 9.11 9.11 0 01-2.46-4.45z"/>
|
||||
<path fill="#54595d" d="M20 18h-1.44a.61.61 0 0 1-.4-.12.81.81 0 0 1-.23-.31L17 15h-5l-1 2.54a.77.77 0 0 1-.22.3.59.59 0 0 1-.4.14H9l4.55-11.47h1.89zm-3.53-4.31L14.89 9.5a11.62 11.62 0 0 1-.39-1.24q-.09.37-.19.69l-.19.56-1.58 4.19zm-6.3-1.58a13.43 13.43 0 0 1-2.91-1.41 11.46 11.46 0 0 0 2.81-5.37H12V4H7.31a4 4 0 0 0-.2-.56C6.87 2.79 6.6 2 6.6 2l-1.47.5s.4.89.6 1.5H0v1.33h2.15A11.23 11.23 0 0 0 5 10.7a17.19 17.19 0 0 1-5 2.1q.56.82.87 1.38a23.28 23.28 0 0 0 5.22-2.51 15.64 15.64 0 0 0 3.56 1.77zM3.63 5.33h4.91a8.11 8.11 0 0 1-2.45 4.45 9.11 9.11 0 0 1-2.46-4.45z"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 732 B |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="0 0 20 16">
|
||||
<path fill="#202122" d="M9.2.825c-.1.207-.148.479-.4.55-.44.065-.906.015-1.35 0-.693-.025-1.387-.118-2.076 0-.47.126-.762.582-.95 1A4.323 4.323 0 0 0 4.149 3.4h-2.15v9.2h16V3.4H4.922c.087-.416.163-.846.45-1.175.178-.185.47-.136.7-.15.97.002 1.933.143 2.9.05.371-.047.65-.364.776-.7l.15-.35-.7-.251zM3.5 5.5h1.25a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15H3.5c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.275 0h1.25c.076 0 .125.074.125.15v1.225c0 .075-.05.15-.124.15h-1.25c-.076 0-.126-.074-.126-.15V5.65c0-.075.05-.15.125-.15zm2.275 0H9.3c.076 0 .126.074.126.15v1.225c0 .075-.05.15-.125.15H8.05a.161.161 0 0 1-.151-.15V5.65a.16.16 0 0 1 .15-.15zm2.25 0h1.251a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15h-1.25c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.276 0h1.25c.076 0 .125.074.125.15v1.225c0 .075-.05.15-.125.15h-1.25c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.275 0h1.225a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15h-1.225a.161.161 0 0 1-.15-.15V5.65a.16.16 0 0 1 .15-.15zM4.576 7.9h1.25c.076 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm2.325 0h1.25a.16.16 0 0 1 .15.15V9.3c0 .076-.074.126-.15.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm2.35 0h1.225a.16.16 0 0 1 .15.15V9.3c0 .076-.074.126-.15.126H9.251c-.075 0-.15-.05-.15-.125V8.05c0-.076.074-.151.15-.151zm2.325 0h1.25c.076 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.15-.05-.15-.125V8.05c0-.076.074-.151.15-.151zm2.325 0h1.25c.075 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm-8.7 2.85h9.6c.07 0 .125.055.125.125v.675c0 .07-.055.125-.125.125H5.2a.123.123 0 0 1-.125-.125v-.675c0-.07.054-.125.125-.125z"/>
|
||||
<path stroke="#202122" stroke-width="1.2" d="M2.719 15.279L17.28.72"/>
|
||||
<path stroke="#202122" stroke-width="1.2" d="M2.719 15.279 17.28.72"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |