You can install the Grunt main project folter "outside" your subproject folder.
-gruntJs folder
---gruntFile.js
-projectSubFolder
---project_1
-----sass
-----css
---project_2
-----sass
-----css
---project_3
-----sass
-----css
You can use dynamic parameters to pass in the task to target the single project you have:
for example:
grunt sass:<projectName>
than in the gruntFile.js you can use something like this:
sass: {
dist: {
files: [{
expand: true,
src: ['../projectSubFolder/<%= grunt.task.current.args[0] %>/sass/*.scss'],
dest: '../projectSubFolder/<%= grunt.task.current.args[0] %>/css',
extDot: 'last',
ext: '.css'
}]
}
},
a generic task that execute it for all the project for example:
grunt.registerTask('sassAll', [ 'sass:project_1', 'sass:project_2', 'sass:project_3' ]);
it is good if you have multiple project that have the same tasks.
if you need to split the taskt than you can creare multiple different tasks, setting up the directory/process for it.
you can add multiple parameters for the grunt task if you want more versatility.
watch: {
less: {
files: ['../projectSubFolder/<%= grunt.task.current.args[0] %>/less/*.less',
'../projectSubFolder/<%= grunt.task.current.args[0] %>/less/**/*.less',
'../projectSubFolder/<%= grunt.task.current.args[0] %>/js/*.js'
],
tasks: [
'less:<%= grunt.task.current.args[0] %><%= grunt.task.current.args[1] %>',
'uglify:<%= grunt.task.current.args[0] %><%= grunt.task.current.args[1] %>'
]
},
},
less: {
project_1: {
options: {
cleancss: true,
compress: true
},
files: {
'../projectSubFolder/<%= grunt.task.current.args[1] %>/css/style.min.css': '../projectSubFolder/<%= grunt.task.current.args[1] %>/less/*.less'
}
},
},
grunt watch:<projectName>:<taskName>