From 523c7e071665fea0860005005f8ffedea3908850 Mon Sep 17 00:00:00 2001 From: Volker E Date: Wed, 6 Feb 2019 22:25:33 -0800 Subject: [PATCH] build: Add Grunt 'svgmin' task and crush SVGs Adding 'grunt-svgmin' package and corresponding 'svgmin' task and also crush in-use SVGs. Bug: T215485 Change-Id: I3a8ba3daab7b7fb110000d88d9baff9ea1f5b5db --- Gruntfile.js | 41 +- package.json | 1 + resources/images/bullet.svg | 4 +- resources/images/headbg-gradient.svg | 18 +- resources/images/headbg.svg | 516 ++++++++++++------------ resources/images/icon-chat.svg | 40 +- resources/images/icon-close.svg | 38 +- resources/images/icon-edit.svg | 78 ++-- resources/images/icon-globe.svg | 34 +- resources/images/icon-page.svg | 30 +- resources/images/icon-search.svg | 54 +-- resources/images/icon-tools.svg | 40 +- resources/images/icon-triangle-down.svg | 24 +- resources/images/icon-triangle-ltr.svg | 24 +- resources/images/icon-triangle-rtl.svg | 24 +- resources/images/icon-triangle-up.svg | 26 +- resources/images/icon-user.svg | 66 +-- 17 files changed, 549 insertions(+), 509 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9aa9be5..fe8f50a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,6 +5,8 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-stylelint' ); + grunt.loadNpmTasks( 'grunt-svgmin' ); + grunt.initConfig( { eslint: { all: [ @@ -33,9 +35,46 @@ module.exports = function ( grunt ) { '!node_modules/**', '!vendor/**' ] + }, + // 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' + } ] + } } } ); + grunt.registerTask( 'minify', 'svgmin' ); grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana', 'stylelint' ] ); - grunt.registerTask( 'default', 'test' ); + grunt.registerTask( 'default', [ 'minify', 'test' ] ); }; diff --git a/package.json b/package.json index 90ed608..bffe6cd 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "grunt-eslint": "21.0.0", "grunt-jsonlint": "1.1.0", "grunt-stylelint": "0.10.1", + "grunt-svgmin": "5.0.0", "stylelint-config-wikimedia": "0.5.0" } } diff --git a/resources/images/bullet.svg b/resources/images/bullet.svg index 181e5be..35c7781 100644 --- a/resources/images/bullet.svg +++ b/resources/images/bullet.svg @@ -1,4 +1,4 @@ - + - + diff --git a/resources/images/headbg-gradient.svg b/resources/images/headbg-gradient.svg index 3100112..d74bfe1 100644 --- a/resources/images/headbg-gradient.svg +++ b/resources/images/headbg-gradient.svg @@ -1,11 +1,11 @@ - + - - - - - - - - + + + + + + + + diff --git a/resources/images/headbg.svg b/resources/images/headbg.svg index 4c742a9..3ae9c86 100644 --- a/resources/images/headbg.svg +++ b/resources/images/headbg.svg @@ -1,260 +1,260 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-chat.svg b/resources/images/icon-chat.svg index 59a6767..43f8e6a 100644 --- a/resources/images/icon-chat.svg +++ b/resources/images/icon-chat.svg @@ -1,22 +1,22 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-close.svg b/resources/images/icon-close.svg index 711e0d6..89421b5 100644 --- a/resources/images/icon-close.svg +++ b/resources/images/icon-close.svg @@ -1,21 +1,21 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-edit.svg b/resources/images/icon-edit.svg index 48fb0b4..cd4489b 100644 --- a/resources/images/icon-edit.svg +++ b/resources/images/icon-edit.svg @@ -1,41 +1,41 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-globe.svg b/resources/images/icon-globe.svg index efcf873..7a47afe 100644 --- a/resources/images/icon-globe.svg +++ b/resources/images/icon-globe.svg @@ -1,19 +1,19 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-page.svg b/resources/images/icon-page.svg index b4499f6..439f121 100644 --- a/resources/images/icon-page.svg +++ b/resources/images/icon-page.svg @@ -1,17 +1,17 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/resources/images/icon-search.svg b/resources/images/icon-search.svg index e672f56..758f0b4 100644 --- a/resources/images/icon-search.svg +++ b/resources/images/icon-search.svg @@ -1,29 +1,29 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-tools.svg b/resources/images/icon-tools.svg index 65c5b56..51024bf 100644 --- a/resources/images/icon-tools.svg +++ b/resources/images/icon-tools.svg @@ -1,22 +1,22 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/icon-triangle-down.svg b/resources/images/icon-triangle-down.svg index 4edd92a..27312f9 100644 --- a/resources/images/icon-triangle-down.svg +++ b/resources/images/icon-triangle-down.svg @@ -1,14 +1,14 @@ - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/resources/images/icon-triangle-ltr.svg b/resources/images/icon-triangle-ltr.svg index e4e3841..2878ab4 100644 --- a/resources/images/icon-triangle-ltr.svg +++ b/resources/images/icon-triangle-ltr.svg @@ -1,14 +1,14 @@ - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/resources/images/icon-triangle-rtl.svg b/resources/images/icon-triangle-rtl.svg index ee04d66..d630fee 100644 --- a/resources/images/icon-triangle-rtl.svg +++ b/resources/images/icon-triangle-rtl.svg @@ -1,14 +1,14 @@ - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/resources/images/icon-triangle-up.svg b/resources/images/icon-triangle-up.svg index 88d024d..7037978 100644 --- a/resources/images/icon-triangle-up.svg +++ b/resources/images/icon-triangle-up.svg @@ -1,15 +1,15 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/resources/images/icon-user.svg b/resources/images/icon-user.svg index e0cf203..310033c 100644 --- a/resources/images/icon-user.svg +++ b/resources/images/icon-user.svg @@ -1,35 +1,35 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +