Reputation: 1918
My images are not being optimized. Perhaps I am doing something wrong on my end but every other task is working for me except my imagemin task. I removed all other tasks and tried to run my task below but it doesn't execute.
There are also no messages in my terminal that indicate what the issue is. I am running this command with
grunt imagemin
but nothing happens.
The images are in .jpg
format and are in my img
folder. What i want to do is optimize/compress these images into my images folder in my dist
folder.
I am also loading all registered nodes with require('load-grunt-tasks')(grunt);
Would be nice if someone could help me out.
Here is my folder structure
Main Folder
| -- dist
|--- css
|--- js
|-- img -- (images are here)
|-- js
|-- node_modules
|-- reports
|-- sass
|-- test
|-- coverage
|-- _resources
|-- _bin
Here is my gruntfile.js
module.exports = function(grunt) {
// A very basic default task.
// grunt.registerTask('running', 'Log some stuff.', function() {
// grunt.log.write('Logging some stuff...').ok();
// });
require('load-grunt-tasks')(grunt); // using this to load all tasks
grunt.initConfig({
// Minify Images
// Optimzes Images
imagemin: { // Task
dynamic: {
files: [{
expand: true,
cwd: 'img/',
src: ['*.{png,jpg,gif}'],
dest: 'dist/images/optimized/'
}]
},
options: {
cache: false
}
}
});
grunt.registerTask('imagemin', ['imagemin']);
Upvotes: 2
Views: 619
Reputation: 1918
I guess you can't have the name of imagemin
as the name of the task. For example I originally had grunt.registerTask('imagemin', ['imagemin']);
All I did was rename my task to something like minimizeImages
grunt.registerTask('minimizeImages', ['imagemin']);
and this worked!
Upvotes: 5