Reputation: 58652
I have more than 100 images in my images/
folder.
// The following *-min tasks produce minified files in the dist folder
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= config.app %>/images',
src: '{,*/*/}*.{gif,jpeg,jpg,png,ico}',
dest: '<%= config.dist %>/images'
}]
}
}
When I run grunt build
I saw this
Running "imagemin:dist" (imagemin) task
Minified 7 images (saved 492.79 kB)
Only 7 of my images got minified. Not all.
I've tried changing the *
around in a diff combination, but so far - no luck.
src: '{,*/*/}*.{gif,jpeg,jpg,png,ico}'
How do I fix my src
to minified everything in my images folder ?
Upvotes: 4
Views: 168
Reputation: 13818
I think the problem might be in the src
globbing pattern. The pattern you are using only matches those images that are in the cwd
root or in a two levels deep ones ({,*/*/}
).
If you want all the images in the cwd
directory to be minified regardless the levels of subdirectories they reside, you should use the **/*
globbing pattern instead:
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= config.app %>/images',
src: '**/*.{gif,jpeg,jpg,png,ico}',
dest: '<%= config.dist %>/images'
}]
}
}
Upvotes: 2