node.js - How to reuse gulp tasks for multiple nodejs projects -
i trying reuse gulp
tasks in 2 different projects. extract gulp
tasks parent directory , trying require them in. here directory structure.
parent/ gulp-tasks/ default.js project1/ node_modules/ gulpfile.js js/ project2/ node_modules/ gulpfile.js js/
this have in gulpfile.js
in each project
var requiredir = require('require-dir'); requiredir('../gulptasks');
here default.js
looks like:
var gulp = require('gulp'); gulp.task('default', function() { //run code here })
when try run gulp default
, gulp
not defined. know there no node_modules
in parent directory, there way point node_modules
in each of child projects? not particularly wanting answer gulp how structure projects make code reusable?
- why need structure way? can break them down repos? way can install each of them dependencies.
- you can have package.json within
parent
root. have access sharednode_modules
folders.
Comments
Post a Comment