Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

build: Replace 'grunt-svgmin' with npm based 'svgo' #495

Merged
merged 2 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .svgo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* SVGO Configuration
* Compatible to v2.4.0+
* Recommended options from:
* https://www.mediawiki.org/wiki/Manual:Coding_conventions/SVG#Exemplified_safe_configuration
*/
module.exports = {
plugins: [
{
// 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
}
}
},
'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: {
eol: 'lf',
finalNewline: true,
// Configure the indent to tabs (default 4 spaces) used by `--pretty` here.
indent: '\t',
pretty: true
},
multipass: true
}
39 changes: 0 additions & 39 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = function ( grunt ) {
grunt.loadNpmTasks( '@lodder/grunt-postcss' );
grunt.loadNpmTasks( 'grunt-replace' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-svgmin' );

grunt.initConfig( {
// Build – JavaScript
Expand Down Expand Up @@ -108,43 +107,6 @@ module.exports = function ( grunt ) {
}
},

svgmin: {
options: {
js2svg: {
indent: '\t',
multipass: true,
pretty: true
},
plugins: [ {
cleanupIDs: false
}, {
removeDesc: true
}, {
removeRasterImages: true
}, {
removeTitle: false
}, {
removeViewBox: false
}, {
removeXMLProcInst: false
}, {
sortAttrs: true
} ]
},
all: {
files: [ {
expand: true,
cwd: './',
src: [
'**/*.svg',
'!img/visual-style/principles-paper-ink.svg'
],
dest: './',
ext: '.svg'
} ]
}
},

replace: {
dist: {
options: {
Expand Down Expand Up @@ -183,7 +145,6 @@ module.exports = function ( grunt ) {
} );

grunt.registerTask( 'lint', [ 'eslint', 'stylelint' ] );
grunt.registerTask( 'images', [ 'svgmin' ] );
grunt.registerTask( 'images-pre-production', [ 'replace' ] );
grunt.registerTask( 'default', [ 'concat', 'uglify', 'postcss:dev', 'postcss:min' ] );
};
Loading