2.0.3 • Published 9 years ago

grunt-svgmin-icons v2.0.3

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

grunt-svgmin Build Status

Minify SVG using SVGO

Issues with the output should be reported on the SVGO issue tracker.

Install

$ npm install --save-dev grunt-svgmin

Usage

require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

grunt.initConfig({
	svgmin: {
		options: {
			plugins: [
				{
					removeViewBox: false
				}, {
					removeUselessStrokeAndFill: false
				}
			]
		},
		dist: {
			files: {
				'dist/unicorn.svg': 'app/unicorn.svg'
			}
		}
	}
});

grunt.registerTask('default', ['svgmin']);

Available Options/Plugins

svgmin makes use of the standard SVGO plugin architecture. Therefore, to customize SVG optimisation, you can disable/enable any SVGO plugins listed at the SVGO repository.

To disable plugins with the Gruntfile.js, look for the plugin name at the SVGO repository and copy the plugin name (minus the file extension). Then set its value in the JSON to false in comma-separated objects. To exemplify, here is how the plugins section in the example configuration (illustrated above) might be written with some of the standard SVGO plugins disabled:

plugins: [
	{ removeViewBox: false }, 				// don't remove the viewbox atribute from the SVG
	{ removeUselessStrokeAndFill: false },	// don't remove Useless Strokes and Fills
	{ removeEmptyAttrs: false }				// don't remove Empty Attributes from the SVG
]

Check each plugin for exports.active = [true/false] to see if the plugin is enabled. Most of the plugins are enabled by default but you may want to prevent a couple, particularly removeUselessStrokeAndFill as that may remove small details with subtracted / extruded complex paths.

License

MIT © Sindre Sorhus