Reputation: 277
I have gruntfile as below:
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
one: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>_ac.js'
},
two: {
src: ['/types/**/*.js'],
dest: 'dist/<%= pkg.name %>_lib.js'
},
all: {
}
},..... and so on
Now if i register the task like: grunt.registerTask('basic', ['concat:all']);
I want both one and two to run. How shall i add this option in
all: {
// what i need to add here to include one and two both?
}
Upvotes: 0
Views: 512
Reputation: 736
You can use 'gruntfile' plugin where you are provided with more powerful functionality and you can add tasks of one grunt file to another using concat.
Refer the link : https://github.com/shama/gruntfile
Upvotes: 1
Reputation: 28665
Grunt allow you to define the main target. So in your default target define as
grunt.registerTask( 'basic',['concat']);
This will activate the concat:one and concat:two.
If you need to activate a specific target, define your register task as follows.
grunt.registerTask( 'basic',['concat:one']);
If you need to run the specific task which has multiple targets then you can define as follows.
all: {
tasks: ['one','two']
}
Then in your registerTask call the all target.
grunt.registerTask( 'basic',['concat:all']);
Hope this might help.
Upvotes: 2
Reputation: 13762
No need to add another target if you're registering a task to point to two targets. Just do:
grunt.registerTask('basic', ['concat:one', 'concat:two']);
Otherwise if you're intending on concatenating the files from one and two all together do:
grunt.initConfig({
concat: {
one: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>_ac.js'
},
two: {
src: ['/types/**/*.js'],
dest: 'dist/<%= pkg.name %>_lib.js'
},
all: {
src: ['<%= concat.one.src %>', '<%= concat.two.src %>'],
dest: 'dist/<%= pkg.name %>_all.js'
}
}
});
Upvotes: 5