build: Bring SVGO optimization to build step

Enabling SVGO automation with 'grunt-svgmin' and conservative
plugin settings to build step, among those:
- enable removeRasterImages and sortAttrs,
- disable cleanupIDs, removeDesc, removeTitle, removeViewBox &
  removeXMLProcInst and
- make use of pretty, indent and multipass options.

Also updating SVG accordingly.

Bug: T185596
Change-Id: I0030a711a2947ca8c1eb4e56d8540661c72a2639
This commit is contained in:
Volker E
2018-02-12 12:01:28 -08:00
committed by jenkins-bot
parent 3990dfe176
commit f3d48beef7
11 changed files with 60 additions and 25 deletions

View File

@@ -6,6 +6,7 @@ module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-svgmin' );
grunt.initConfig( {
eslint: {
@@ -36,9 +37,46 @@ module.exports = function ( grunt ) {
'!vendor/**'
]
},
banana: conf.MessagesDirs
banana: conf.MessagesDirs,
// SVG Optimization
svgmin: {
options: {
js2svg: {
indent: ' ',
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', 'stylelint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
grunt.registerTask( 'default', [ 'minify', 'test' ] );
};