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'
}
}
Custom tasksYou can configure Grunt to run one or more tasks by default by defining a default task. In the following example, running grunt at the command line without specifying a task will run the uglify task. This is functionally the same as explicitly running grunt uglify or even grunt default .
When a task is run, Grunt looks for its configuration under a property of the same name. Multi-tasks can have multiple configurations, defined using arbitrarily named "targets." In the example below, the concat task has foo and bar targets, while the uglify task only has a bar target.
grunt-este-watchby Daniel SteigerwaldRun predefined tasks whenever watched file changes.
Check with the name, if a task exists in the registered tasks.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With