Sub Gruntfile.js Inheriting node_modules from the root

1

I'm in a project (in laravel 4.2) where they made a mega Gruntfile.js, so I decided to organize and create a Gruntfile.js for each set of project assets.

The problem: I do not want to have to give a 'npm install' for each subproject (because for each subproject I have a Gruntfile.js and a package.json), then I tried to force the node_modules to read in the root , with:

module.exports = function(grunt) { "use strict";

//força path do node_modules (pra nao ter que baiar novamente)
grunt.file.setBase('../../../');

//força a leitura das dependencias do package.json principal
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);

grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"), //meu atual
    ...
});
}

This function worked, or else, when I force the dir into 'node_modules' it also reads Gruntfile.js from the root and then ends up performing some unwanted tasks.

Does anyone have a light?

Project Structure:
/ app
/ xpto
/ public
/ assets
/ proj1
/ js
/ css
/ img
-Gruntfile.js
-package.json
/ proj2
/ js
/ css
/ img
-Gruntfile.js
-package.json
Gruntfile.js (default)
package.json     

asked by anonymous 12.02.2016 / 22:30

1 answer

0

My code was working, it only read the parent Gruntfile.js during the "watch" command

I put in this task an options: {cwd: ""} and it worked 100% now

    
17.02.2016 / 19:38