简体   繁体   中英

grunt imagemin gives : Minified 0 images..?

As I enter grunt imagemin it gives as a result : 'Minified 0 images'

What I did:

npm install grunt-contrib-imagemin --save-dev

Installed imagemin plug-in

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),

imagemin:{
  dynamic:{
    files: [{
      expand:true,
      cwd: 'images/',
      src: ['**/*.{png,jpg}'],
      dest: 'images/build'
    }]
  }
}

});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-imagemin');

// Default task(s).
grunt.registerTask('default', ['concat', 'uglify', 'imagemin']);

};

Changed Grunt.js file configuration

grunt imagemin

Entered on terminal..

Why wouldn't it optimize the images?

Thanks in advance!

I found it..

I had a wrong path..

imagemin:{
  dynamic:{
  files: [{
  expand:true,
  cwd: 'images/',   // This had to be img/
  src: ['**/*.{png,jpg}'],
  dest: 'images/build'
  }]
}
}

Plus, I don't set concat and uglify plugin above so default tasks definition was wrong too

// Default task(s).
grunt.registerTask('default', ['concat', 'uglify', 'imagemin']); 

must be

// Default task(s).
grunt.registerTask('default', ['imagemin']);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM