1 | gulp-loader
|
2 | ===========
|
3 |
|
4 | [![Build Status](https://travis-ci.org/call-a3/gulp-loader.svg?tag=1.1.0)](https://travis-ci.org/call-a3/gulp-loader)
|
5 | [![Dependency Status](https://david-dm.org/call-a3/gulp-loader.svg)](https://david-dm.org/call-a3/gulp-loader) [![devDependency Status](https://david-dm.org/call-a3/gulp-loader/dev-status.svg)](https://david-dm.org/call-a3/gulp-loader#info=devDependencies)
|
6 |
|
7 | Gulp plugin that wraps gulp and loads tasks from a specified folder. Task definitions are compatible with [gulp-task-loader](https://www.npmjs.org/package/gulp-task-loader).
|
8 |
|
9 | ## Installation
|
10 |
|
11 | [![gulp-loader](https://nodei.co/npm/gulp-loader.png?mini=true)](https://nodei.co/npm/gulp-loader)
|
12 |
|
13 | ## Usage
|
14 | Just write this in your gulpfile.js
|
15 | ```javascript
|
16 | /*
|
17 | instead of require('gulp') and then defining tasks on it
|
18 | just write the following
|
19 | */
|
20 | require('gulp-loader')();
|
21 | ```
|
22 |
|
23 | Now create a folder next to your gulpfile.js called `gulp` and have them contain tasks like this:
|
24 | ```javascript
|
25 | /*
|
26 | no need to require('gulp')
|
27 | because gulp is already defined in the scope of the module
|
28 | */
|
29 | module.exports = function () {
|
30 | gulp.src('...')
|
31 | // your gulp task here
|
32 | .pipe(gulp.dest('...'));
|
33 | }
|
34 |
|
35 | // the following line is optional
|
36 | module.exports.dependencies = ['dep1', 'dep2'];
|
37 | ```
|
38 | (Note: this setup is compatible with [gulp-task-loader](https://www.npmjs.org/package/gulp-task-loader).)
|
39 | You can also write tasks in coffeescript.
|
40 |
|
41 | ## Extra features
|
42 | gulp-loader wraps the gulp library in a backwards-compatible way and exposes it to the tasks.
|
43 | This means you can define your tasks as if gulp was pre-loaded, but you can also use some shortcuts or extra features.
|
44 |
|
45 | ### gulp.util
|
46 | This exposes the gulp-util library. In other words, you can use `gulp.util` instead of
|
47 | ```
|
48 | var gutil = require('gulp-util');
|
49 | gutil.log(); // or whatever gulp-util function you would use
|
50 | ```
|
51 |
|
52 | ### gulp.debug
|
53 | Contains a boolean indicating if the build should assume a develop/debug environment. The default is to assume debugging is needed unless `--target=production` was provided on the command line. You can use this to adjust build behaviour based on whether debugging is required.
|
54 |
|
55 | ```bash
|
56 | # Usage on the terminal looks like the following
|
57 | gulp --target=production $task
|
58 | ```
|
59 |
|
60 | ### gulp.name
|
61 | Contains a string that represents the name of the package. This consists of package.name + '@' + package.version + '.js', wherein package is loaded from package.json. The character '@' can be replaced by another by setting the option `gulp.name.infix`. Similarly, the extension can be set differently by setting the option `gulp.name.extension`.
|
62 |
|
63 | ### gulp.dirs
|
64 | A hash containing `source`, `test`, `build` and `dist` values. These are set from values in the "gulp" entry in package.json using the same names and default to 'src', 'test', 'build' and 'dist' respectively. Each of these folders is resolved relative to the parent of gulpfile.js.
|
65 |
|
66 | ### gulp.main
|
67 | Returns the full pathname of package.main or `gulp.dirs.source + '/main.js'` if none is set in package.json.
|
68 |
|
69 | ### gulp.src()
|
70 | You can use the gulp.src() function without globPattern parameters. This defaults to streaming every file in the `gulp.dirs.source` folder. You can also still use the function as you would the normal gulp.src(globPattern) function.
|
71 |
|
72 | ### gulp.dest()
|
73 | You can use the gulp.dest() function without path parameter. This defaults to streaming every file to the `gulp.dirs.build` folder. You can also still use the function as you would the normal gulp.dest(path) function.
|
74 |
|
75 | ### gulp.deploy()
|
76 | The gulp.deploy() function works similarly to gulp.dest(). This streams every file to the `gulp.dirs.test` or `gulp.dirs.dist` folder, depending on the value of `gulp.debug`.
|
77 |
|
78 | ### gulp.task('clean')
|
79 | By default, the task 'clean' is defined. This clears every file from the `gulp.dirs.build` folder. This tasks also comes in the variants `clean:test` and `clean:dist` to clear the directories `gulp.dirs.test` or `gulp.dirs.dist` respectively.
|
80 |
|
81 | ### gulp.task('deploy')
|
82 | By default, the task 'deploy' is defined. This moves every file from the `gulp.dirs.build` folder into either `gulp.dirs.test` or `gulp.dirs.dist`, depending on the value of `gulp.debug`.
|
83 |
|
84 | ### _Other features_
|
85 |
|
86 | _As this tool is currently in a alpha stage, I am also very open to feature requests at this stage. If you want to request a feature, I would prefer it if you did so by creating a test for it and created a pull request for it. If you do this, use 'FR ' + description of your feature as the title of the pull request._
|
87 |
|
88 | _If you REALLY want a certain feature to get incorporated quickly, you can ofcourse implement it yourself ;) However, I will NOT accept features that aren't accompagnied by their own tests._
|
89 |
|
90 | ## License
|
91 | [MIT](http://github.com/call-a3/gulp-loader/blob/master/LICENSE)
|