Permalink
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (33 sloc) 1.05 KB

Split tasks across multiple files

If your gulpfile.js is starting to grow too large, you can split the tasks into separate files by using the gulp-hub module as a custom registry.

Imagine the following file structure:

gulpfile.js
tasks/
├── dev.js
├── release.js
└── test.js

Install the gulp-hub module:

npm install --save-dev gulp@next gulp-hub

Add the following lines to your gulpfile.js file:

'use strict';

var gulp = require('gulp');
var HubRegistry = require('gulp-hub');

/* load some files into the registry */
var hub = new HubRegistry(['tasks/*.js']);

/* tell gulp to use the tasks just loaded */
gulp.registry(hub);

This recipe can also be found at https://github.com/frankwallis/gulp-hub/tree/4.0/examples/recipe