Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a directory from grunt-contrib-imagemin

I have the following snippet in my Gruntfile.js:

    imagemin: {
        options: {
            optimizationLevel: 7,
            cache: false
        },

        dist: {
            files: [{
                expand: true,
                cwd: 'Assets/img/',
                src: ['**/*.{png,jpg,gif}', '!optimised/*.*'],
                dest: 'Assets/img/optimised/'
            }]
        }
    }

When I run grunt imagemin the files in /optimised get optimised again, what's the correct pattern to make sure I exclude whatever files I have in my 'optimised' folder?

I've tried the globbing pattern ! that's used to negate a match but can't make it work.

like image 518
Chris Avatar asked Feb 03 '15 12:02

Chris


1 Answers

Just found the answer, maybe this might help someone else as I couldn't find anything like it on SO.

src: ['**/*.{png,jpg,gif}', '!optimised/**']

More about globbing patterns: http://gruntjs.com/configuring-tasks#globbing-patterns

like image 64
Chris Avatar answered Oct 13 '22 19:10

Chris