khollenbeck
khollenbeck

Reputation: 16157

Grunt Concat Task, how to ignore all .min.js files?

I have the following grunt concat task. How can I make concat ignore all minified files? This doesn't work.

concat: {
    js: {
        src:  [ 
            '<%= globalConfig.bar %>', 
            '<%= globalConfig.foo %>/*.js', 
            '<%= globalConfig.foo %>/!*.min.js', 
            '<%= globalConfig.fooLib %>/*.js', 
            '<%= globalConfig.fooLib %>/!*.min.js'
        ],
        dest: '../../foo/fooCombined.js'
    },
    css: {
        src: ['<%= globalConfig.foo %>/*.css'],
        dest: '../../foo/fooCombined.css'
    }
},

This also doesn't work:

'<%= globalConfig.fooLib %>/(*.js && !*min.js)'

Any help is appreciated. Thanks.

Upvotes: 15

Views: 7992

Answers (1)

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

Try this:

concat: {
  js: {
    src:  [ 
        '<%= globalConfig.bar %>', 
        '<%= globalConfig.foo %>/*.js', 
        '<%= globalConfig.fooLib %>/*.js', 
        '!**/*.min.js'
    ],
    dest: '../../foo/fooCombined.js'
  },
  css: {
    src: ['<%= globalConfig.foo %>/*.css'],
    dest: '../../foo/fooCombined.css'
  }
},

Negate or ! is placed at the beginning of a valid pattern to produce the opposite effect. Patterns are processed in order, so placing a negated pattern that you wish to exclude at the end, will do the trick.

See http://gruntjs.com/configuring-tasks#globbing-patterns for more info.

Upvotes: 33

Related Questions