Skip to content

Commit f7e7d4c

Browse files
committed
Docs: Update "split tasks" recipe to use gulp-hub
1 parent 6c46116 commit f7e7d4c

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed
Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
# Split tasks across multiple files
22

3-
If your `gulpfile.js` is starting to grow too large, you can split
4-
the tasks into separate files using one of the methods below.
5-
6-
> Be advised, that this approach is [considered deprecated][deprecated]
7-
> and could lead to problems when migrating to the `gulp 4`.
8-
9-
10-
## Using `gulp-require-tasks`
11-
12-
You can use the [gulp-require-tasks][gulp-require-tasks]
13-
module to automatically load all your tasks from the individual files.
14-
15-
Please see the [module's README][gulp-require-tasks] for up-to-date instructions.
16-
17-
## Using `require-dir`
18-
19-
You can also use the [require-dir][require-dir] module to load your tasks manually.
3+
If your `gulpfile.js` is starting to grow too large, you can split the tasks
4+
into separate files by using the [gulp-hub](https://github.com/frankwallis/gulp-hub/tree/4.0)
5+
module as a [custom registry](https://github.com/phated/undertaker#registryregistryinstance).
206

217
Imagine the following file structure:
228

@@ -28,20 +14,25 @@ tasks/
2814
└── test.js
2915
```
3016

31-
Install the `require-dir` module:
17+
Install the `gulp-hub` module:
3218

3319
```sh
34-
npm install --save-dev require-dir
20+
npm install --save-dev gulp-hub
3521
```
3622

3723
Add the following lines to your `gulpfile.js` file:
3824

3925
```js
40-
var requireDir = require('require-dir');
41-
var tasks = requireDir('./tasks');
42-
```
26+
'use strict';
27+
28+
var gulp = require('gulp');
29+
var HubRegistry = require('gulp-hub');
4330

31+
/* load some files into the registry */
32+
var hub = new HubRegistry(['tasks/*.js']);
33+
34+
/* tell gulp to use the tasks just loaded */
35+
gulp.registry(hub);
36+
```
4437

45-
[gulp-require-tasks]: https://github.com/betsol/gulp-require-tasks
46-
[require-dir]: https://github.com/aseemk/requireDir
47-
[deprecated]: https://github.com/gulpjs/gulp/pull/1554#issuecomment-202614391
38+
This recipe can also be found at https://github.com/frankwallis/gulp-hub/tree/4.0/examples/recipe

0 commit comments

Comments
 (0)