is it possible to configure grunt in a way that you have the required modules on a central point?
I have following project structure
-Project
-- subproject
-- subproject
-- subproject
I build the project via grunt with all subprojects, and I can build each subproject for itself too. Currently I have a Gruntfile.js, package.json & folder node_modules (~50mb) with all required modules in each subproject and on the root level.
So is it possible to have the node_modules folder only on one level, for e.g. on the root level and the subprojects refer to the node_modules on root level?
-Project
--subproject
--subproject
--subproject
--node_modules
Is there a way to reference the node_module folder via package.json or anything else?
Edit:
Gruntfile.js (subproject level)
/*global module:false */
/*jshint node:true */
module.exports = function(grunt) {
"use strict";
// ================================================================================
// project configuration
// ================================================================================
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
jshint: {
globals : {
d3:true,
Modernizr:true,
tempo:true
},
options: grunt.file.readJSON('.jshintrc')
},
csslint: {
subproject: {
src: 'css/**/*.css'
}
},
htmllint : {
subproject: {
src: 'html/**/*.html'
}
},
clean : [ 'output' ],
less : {
options: {
paths: ['./']
},
src: {
expand: true,
cwd: 'css/',
src: ['**/*.less'],
dest: 'css/',
ext: '.css'
}
},
copy: {
subproject: {
files: [
{src: ['img/**', 'js/**', 'folderX/**','!**/*.less'], dest: 'output/subproject/'}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-html');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
// ================================================================================
// default task
// ================================================================================
grunt.registerTask('default', ['clean', 'less', 'csslint', 'htmllint', 'copy']);
};
package.json (subproejct level)
{
"description": "subproject",
"title": "Lorem Ipsum",
"devDependencies": {
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-less": "~0.5.0",
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-qunit": "~0.1.1",
"grunt-css": "~0.5.4",
"grunt-contrib-clean": "~0.4.0",
"grunt-html": "~0.3.3",
"grunt-contrib-concat": "~0.1.3"
}
}
BR, mybecks