How to use the imagemin.svgo function in imagemin

To help you get started, we’ve selected a few imagemin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kurtz1993 / ionic-minify / after_prepare / ionic-minify.js View on Github external
},
                fromString: true
            });
            fs.writeFileSync(file, result.code, 'utf8'); // overwrite the original unminified file
            break;
        case '.css':
            console.log('Minifying CSS File: ' + file);
            var source = fs.readFileSync(file, 'utf8');
            var result = cssMinifier.minify(source);
            fs.writeFileSync(file, result, 'utf8'); // overwrite the original unminified file
            break;
        // Image options https://github.com/imagemin/imagemin
        case '.svg':
            console.log('Minifying SVG File: ' + file);
            // svgGo options https://github.com/imagemin/imagemin#svgo
            imagemin.src(file).dest(file).use(ImageMin.svgo());
            break;
        case '.gif':
            console.log('Minifying GIF File: ' + file);
            // GifSicle options https://github.com/imagemin/imagemin#gifsicle
            imagemin.src(file).dest(file).use(ImageMin.gifsicle({
                interlaced: true
            }));
            break;
        case '.png':
            console.log('Minifying PNG File: ' + file);
            // OptiPNG options https://github.com/imagemin/imagemin#optipng
            imagemin.src(file).dest(file).use(ImageMin.optipng({
                optimizationLevel: 2
            }));
            break;
        case '.jpg':
github webframes / webframes / lib / util / minify.js View on Github external
{
			if (!jpg) jpg = new Imagemin().use( Imagemin.jpegtran({progressive:true}) );
			instance = jpg;
			break;
		}
		case "png":
		{
			if (!png) png = new Imagemin().use( Imagemin.optipng({optimizationLevel:7}) );	// 0-7
			instance = png;
			break;
		}
		default:
		{
			if (!svg)
			{
				svg = new Imagemin().use( Imagemin.svgo({plugins:[
				{
					collapseGroups: false,
					convertStyleToAttrs: false,	// didn't support base64 strings within inline CSS (svgo v0.4.4)
					moveGroupAttrsToElems: false
				}]}) );
			}
			instance = svg;
		}
	}
	
	return instance;
}
github rincojs / rinco-sg / lib / build.js View on Github external
m.img = function () {

  var Imagemin = require('imagemin');

  new Imagemin()
      .src(fs.path.join(config.IMG_DIR,'*.{gif,jpg,png,svg}'))
      .dest(fs.path.join(config.BUILD_DIR,'assets','img'))
      .use(Imagemin.jpegtran({progressive: true}))
      .use(Imagemin.gifsicle({interlaced: true}))
      .use(Imagemin.optipng({optimizationLevel: 3}))
      .use(Imagemin.svgo())
      .run(function (err, files) {
          files.map(function (file) {
              console.log(file);
              sh.echo('[ok]'.green);
          });
      });
};
github sourcey / s3-image-optimizer / optimizer.js View on Github external
function process(meta, obj, next) {
      new Imagemin()
        .src(obj.Body)
        .use(Imagemin.jpegtran(imageminOptions))
        .use(Imagemin.gifsicle(imageminOptions))
        .use(Imagemin.optipng(imageminOptions))
        .use(Imagemin.svgo({plugins: imageminOptions.svgoPlugins || []}))
        .run(function(err, files) {
          if(err) return next(err);
          console.log('Optimized! Final file size reduced from ' + obj.Body.length + ' to ' + files[0].contents.length + ' bytes');
          next(null, meta, obj, files[0])
        });
    },