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?

  1. why need structure way? can break them down repos? way can install each of them dependencies.
  2. you can have package.json within parent root. have access shared node_modules folders.

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -