I have few projects in separate directories and want to build them in the same way. I want to define project name from task (as param). Grunt tasks will use this project path as root path. But I have several subfolders and do not want to update it manually I just want to update the project. There is any chance to do that?
grunt.initConfig({
paths : {
project : null,
projectStylesheets : '<%= paths.project %>/stylesheets',
// ...
}
});
grunt.registerTask('server', function(project) {
// -> project = 'some_name'
var paths = grunt.config.get('paths');
paths.project = project;
grunt.config.set('paths', paths);
// -> { project: 'some_name', projectAssets: 'stylesheets' }
});
I was thinking about using JS functions outside he config but not sure is this the best practice.
Try use registermultitask - http://gruntjs.com/api/grunt.task#grunt.task.registermultitask
grunt.initConfig({
projectName1 : {
projectStylesheets: 'path_to_stylesheets1',
},
projectName2 : {
projectStylesheets: 'path_to_stylesheets2',
}
})
grunt.registerMultiTask('server', function() {
var path = grunt.data.projectStylesheets;
//operations with stylesheets
});
For build use
grunt server:projectName1
grunt server:projectName2
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