A melhor configuração para otimizar .png e .jpg com grunt-contrib-imagemin.
grunt.initConfig({
imagemin: {
png: {
options: {
optimizationLevel: 7
},
files: [
{
expand: true,
cwd: 'project-directory/img/', // cwd is 'current working directory'
src: ['**/*.png'],
dest: 'project-directory/img/compressed/', // Could also match cwd.
ext: '.png'
}
]
},
jpg: {
options: {
progressive: true
},
files: [
{
expand: true, // Tell Grunt where to find our images and where to export them to.
cwd: 'project-directory/img/', // cwd is 'current working directory'
src: ['**/*.jpg'],
dest: 'project-directory/img/compressed/', // Could also match cwd.
ext: '.jpg'
}
]
}
}
});
grunt.registerTask('default', ['imagemin']);