Imagine we have a central repository named REPO containing multiple grunt projects. Now, let's say we want to structure it like this:
ROOT
-- bower_components
-- node_modules
-- project_1
-- project_2
-- project_3 etc
The current issue is that I need a different gruntfile.js for each project in order to have unique distributed minified js files and tasks.
Currently, each project folder has its own node_module folder with all the required modules which isn't very helpful.
I would like to change it to the following schema:
ROOT
-- bower_components
-- project_1
---- node_modules
-- project_2
---- node_modules
-- project_3
---- node_modules
Each gruntfile will look something like this:
function config(name) {
return require ('./tasks/' + name + '.js');
}
module.exports = function (grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: config('jshint'),
concat: config('concat'),
uglify: config('uglify'),
cssmin: config('cssmin'),
jsbeautifier: config('jsbeautifier'),
watch: {
options: {livereload: true},
files: ['index.html', 'app/views/**/*.html', 'app/css/*.css', 'js/*.js'],
tasks: ['jshint']
},
karma: {
unit: {
configFile: 'test/test.conf.js'
}
}
});
//load plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-karma');
//tasks
grunt.registerTask('dist', ['jshint', 'concat', 'uglify', 'cssmin', 'jsbeautifier']);
grunt.registerTask('default', ['watch']);
};
Is there a way to specify a path for each NpmTask instead of having to install the modules separately for each project in my REPO?
If you need more information or if my English is unclear, feel free to ask and I'll update my question.
Thank you!