Skip to content

tanamako/grunt-auto-imageoptim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-imageoptim-watch

What you can do with grunt

  1. Gruntでimageoptim, imageminを実行
  2. 指定したフォルダの追加、変更をwatchして自動的に画像最適化可能

How to use

I first install the following plug-ins

  1. grunt-conrib-imagemin (https://github.com/gruntjs/grunt-contrib-imagemin)
  2. grunt-imageoptim (https://github.com/JamieMason/grunt-imageoptim)
  3. grunt-contrib-livereload (https://github.com/gruntjs/grunt-contrib-livereload)
  4. grunt-contrib-watch (https://github.com/gruntjs/grunt-contrib-watch)

Livereload & Watch

It performs the task if you will be monitoring the filepath set by the task of imagemin and imageoptim, changes and additions were made.

  changedFiles = Object.create(null);
  onChangeImage = grunt.util._.debounce(function() {
    var filesArray, paths;
    paths = Object.keys(changedFiles);
    filesArray = [];
    paths.forEach(function(path) {
      filesArray.push({
        src: path,
        dest: path
      });
    });
    grunt.config(['imageoptim', 'feature', 'files'], filesArray);
    grunt.config(['imagemin', 'ondemand', 'files'], filesArray);
    changedFiles = Object.create(null);
  }, 200);

Imageoptim App

Install from here.
http://imageoptim.com/
Alt text

Licence

The MIT License (MIT)

About

gruntによる画像最適化の自動化

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published