Files
mediawiki-extensions-Univer…/Gruntfile.js
Volker E f3d48beef7 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
2018-05-20 08:55:05 +00:00

83 lines
1.5 KiB
JavaScript

/* eslint-env node, es6 */
module.exports = function ( grunt ) {
var conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-svgmin' );
grunt.initConfig( {
eslint: {
all: [
'**/*.js',
'!lib/**',
'!node_modules/**',
'!vendor/**',
'!resources/js/ext.uls.webfonts.repository.js'
]
},
stylelint: {
options: {
syntax: 'less'
},
src: [
'**/*.css',
'**/*.less',
'!lib/**',
'!node_modules/**',
'!vendor/**'
]
},
jsonlint: {
all: [
'**/*.json',
'!node_modules/**',
'!vendor/**'
]
},
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', [ 'minify', 'test' ] );
};