9

I need to be able to run multiple tasks of the same type of task within Grunt (grunt-contrib-concat). I've tried a couple of things below but neither work. Any ideas on how to do this are appreciated.

concat: {
    dist: {
        src: [
            'js/foo1/bar1.js',
            'js/foo1/bar2.js'
        ],
        dest: 'js/foo1.js',
        src: [
            'js/foo2/bar1.js',
            'js/foo2/bar2.js'
        ],
        dest: 'js/foo2.js'
    }
}

and..

concat: {
    dist: {
        src: [
            'js/foo1/bar1.js',
            'js/foo1/bar2.js'
        ],
        dest: 'js/foo1.js'
    }
},
concat: {
    dist: {
        src: [
            'js/foo2/bar1.js',
            'js/foo2/bar2.js'
        ],
        dest: 'js/foo2.js'
    }
}

and..

concat: {
    dist: {
        src: [
            'js/foo1/bar1.js',
            'js/foo1/bar2.js'
        ],
        dest: 'js/foo1.js'
    },
    dist: {
        src: [
            'js/foo2/bar1.js',
            'js/foo2/bar2.js'
        ],
        dest: 'js/foo2.js'
    }
}
user2565123
  • 293
  • 1
  • 5
  • 12
  • My question is answered here: http://stackoverflow.com/questions/21918202/using-grunt-to-concat-many-files-from-many-dirs-into-single-renamed-file-in-new?rq=1 – user2565123 Mar 20 '14 at 16:54

1 Answers1

34

First define two targets for the task:

concat: {
    dist1: {
        src: [
            'js/foo1/bar1.js',
            'js/foo1/bar2.js'
        ],
        dest: 'js/foo1.js'
    },
    dist2: {
        src: [
            'js/foo2/bar1.js',
            'js/foo2/bar2.js'
        ],
        dest: 'js/foo2.js'
    }
}

Then register a new task that runs both:

grunt.registerTask('dist', ['concat:dist1', 'concat:dist2']);

Then run using

grunt dist
jgillich
  • 71,459
  • 6
  • 57
  • 85