We have a bunch of applications sharing common gulp logic, so we made a gulp plugin that contains a bunch of custom tasks.
However we\'d like to avoid installing gulp+o
Alternatively to the accepted answer, you can do it the way that was popular in grunt times, where you inject gulp to the plugin:
In plugin: wrap everything with:
module.exports = function(gulp) {
gulp.task('foo', function () {
...
})
...
}
and remove require('gulp')
from the plugin's file.
In gulpfile that depends on plugin you then do:
var gulp = require('gulp');
require('my-gulp-plugin')(gulp)
That way
gulp.tasks
.gulp
a package.json
dependency in each of the plugins (less work for npm install
)Figured it out. Added the following line at the bottom of my module:
module.exports = gulp;
And my gulpfile in each module looks like this:
var gulp = require('gulp');
var mygulpplugin = require('mygulpplugin');
gulp.tasks = mygulpplugin.tasks;