Home

Awesome

grunt-webp

Convert your images to WebP format.

Getting Started

To install this plugin, open up the terminal, cd to your project's root directory and run the following command:

npm install grunt-webp --save-dev

This plugin depends on WebP's cwebp encoder. You'll need to install the WebP Package or use webp-bin

In your Gruntfile.js file add the following line:

grunt.loadNpmTasks('grunt-webp');

This plugin requires Grunt ~0.4.0

Settings

Example

module.exports = function(grunt) {

  
  grunt.initConfig({
	// WebP configuration
    webp: {
      files: {
        //expand: true,
        //cwd: 'path/to/source/images',
        src: 'source/*.png',
        dest: 'output/path/'
      },
      options: {
        binpath: require('webp-bin').path,
        preset: 'photo',
        verbose: true,
        quality: 80,
        alphaQuality: 80,
        compressionMethod: 6,
        segments: 4,
        psnr: 42,
        sns: 50,
        filterStrength: 40,
        filterSharpness: 3,
        simpleFilter: true,
        partitionLimit: 50,
        analysisPass: 6,
        multiThreading: true,
        lowMemory: false,
        alphaMethod: 0,
        alphaFilter: 'best',
        alphaCleanup: true,
        noAlpha: false,
        lossless: false
      }
    }

  });

  // load npm task
  grunt.loadNpmTasks('grunt-webp');

  // register task
  grunt.registerTask('default', 'webp');

};