Caleb Bertrand
Caleb Bertrand

Reputation: 414

Ignore all files in folder grunt concat

I am trying to concatenate all js files in the root and in any other folders of my app, but ignore any files in the node_modules folder. For some reason this setup still takes the node modules, too:

 concat: {
            dist: {
                src: ['*.js', '**/*.js', '!node_modules/*.js'],
                dest: 'concat.js'
            }
        },

Thanks so much

Upvotes: 0

Views: 297

Answers (1)

RobC
RobC

Reputation: 25042

To negate matching the whole node_modules directory use this glob pattern:

'!node_modules/**/*.js'
  1. You probably need to also negate your Gruntfile.js too, in which case you can include multiple ! negation patterns.
  2. Also, as concat.js is being written to the projects root directory, you'll need to negate that too to exclude that on subsequent runs of the task.

For example:

concat: {
  dist: {
    src: ['*.js', '**/*.js', '!node_modules/**/*.js', '!Gruntfile.js', '!concat.js'],
    dest: 'concat.js'
  }
},

Upvotes: 1

Related Questions