gulp-bucket
Maximize gulp tasks reusability.
Installation
npm install gulp-bucket
You can then require gulp-bucket:
var bucket =
What problems does gulp-bucket solve?
Code reusability
gulp-bucket offers a way to define a task once and reuse it as much as needed by putting the emphasis on agnostic definitions. No more hard coded paths!
Tasks dependencies
With gulp, a task's dependency is just a list of tasks names e.g: gulp.task('foo', ['bar', 'quz'], function () {})
.
So even if you are defining your tasks in separate file, you might still have to hard code the dependencies.
gulp-bucket tries to make this process simpler by allowing you to define a task's dependencies right from the task itself:
{ return bucket {} }
Have a look at the example for more details.
Implicit declarations
Whenever you create a new factory, gulp-bucket automatically creates a task that's going to run every tasks created from it.
So basically, if you add a scripts
factory and a foo
task with it, you'll end up with two tasks: scripts
and scripts:foo
.
In this case, scripts
would run scripts:foo
.
Available tasks
There are a few tasks that comes with gulp-bucket
:
tasks/help.js
: a task that display all available tasks with some fancy colors.- Installation:
bucket.factory('help', require('gulp-bucket/tasks/help')).add()
- Installation:
Example
Structure
|__gulp/
|____tasks/
|______lint.js
|______scripts.js
|______styles.js
|______watch.js
|____config.json
|__eslint.json
|__gulpfile.js
gulpfile.js
var bucket = var yargs = var scripts = var styles = var watch = var config = bucket optionsyargsargv bucket bucket
gulp/config.json
gulp/tasks/lint.js
var gulp = var eslint = module { return { return gulp } }
gulp/tasks/scripts.js
var gulp = var bucket = var uglify = var lint = module { return configlint !== false ? bucket : null { var stream = gulp if optionsbuild === true stream = stream stream = stream return stream } }
gulp/tasks/styles.js
var gulp = var sass = var autoprefixer = module { return { return gulp } }
gulp/tasks/watch.js
var gulp = module { return { var deps = Array ? deps : configdeps return gulp } }
Note: a default task is created by bucket.main()
which takes an array of dependencies, flatten it and use it for the "default" task.
Change Log
1.1.0 - 2016-04-10
- Add
before
to run tasks before a factory's root task - Add
defaults
to define a config's defaults for a factory - Fix the factory's root task to properly notify its end
1.0.0 - 2016-03-20
- First release