Reputation: 3848
asume that we have a repository name REPO which is includes several grunt projects. And let's asume we want that the structure:
ROOT
-- bower_components
-- node_modules
-- project_1
-- project_2
-- project_3 etc
Now the issue is that i need for each project a different gruntfile.js so i can have for example a different distributed minified js file, different tasks etc.
The solution i've got for now but isn't at all helpfull is that each project folder has it's own node_module folder with all the needed modules.
So i;ve got this and i want to change it like the schema above.
ROOT
-- bower_components
-- project_1
---- node_modules
-- project_2
---- node_modules
-- project_3
---- node_modules
Now each gruntfile looks like that:
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']);
};
Can i add a path for each NpmTask instead of installing the modules for each project in my REPO?
Please if you need more info or my English are bad ask me anything and i'll update my question.
Thanks
Upvotes: 0
Views: 153
Reputation: 4572
You can use load-grunt-parent-tasks to do that.
I recognize I did not use this plugin, but I think I will help you.
Upvotes: 1