Grunt在node_modules的同一个文件夹中查找,但是如何判断它在不同的文件夹路径中?我希望它在“./js/vendor”中查找其模块
答案 0 :(得分:0)
这似乎与Grunt的GitHub问题跟踪器问题#696中所描述的一样。
// if you want to overload the directory on the CLI
grunt --dir=<your dir to search>
// example CLI command (relative to Gruntfile)
grunt --dir=${PWD}/js/vendor2
/**
* Add the following code to your
* Gruntfile.
*/
// set the custom or default directory
var customDir = grunt.option('dir') || process.cwd() + '/js/vendor';
// get the current working directory
var cwd = process.cwd();
// switch to custom directory (contains node_modules folder)
process.chdir(customDir);
// load taks(s)
grunt.loadNpmTasks('grunt-browserify2');
// switch back to original directory
process.chdir(cwd);