1.0.1 • Published 7 years ago
classy-gulp v1.0.1
classy-gulp
Classy gulp is a written on top of Gulp's undertaker-registry, which enables you to write your gulpfiles in a more readable manner with ES6 classes.
Getting Started
Install the latest version from npm:
npm install classy-gulp --save-dev
Usage
WARNING: do not name any of your class methods init
. init
as an internal undertaker-registry method and your method will be replaced.
In your gulpfile.js:
const gulp = require('gulp'),
ClassyGulp = require('classy-gulp');
class MyGulp extends ClassyGulp {
constructor() {
super();
}
// override the defineTasks function to return an object of your tasks. This is going to be called automatically by classy-gulp.
defineTasks() {
return {
scripts: this.scripts,
build: gulp.parallel(this.styles, 'scripts'),
watch: this.watch,
deploy: gulp.series('build'),
default: gulp.series('build', 'watch'),
};
}
scripts(){
/* handling babel etc. */
}
styles(){
/* handling sass etc. */
}
watch(done) {
gulp.watch('src/**/*.scss', this.styles);
gulp.watch('src/**/*.js', gulp.series('scripts', /* reload browser etc. */));
done();
}
}
// register the regitstry instance with gulp.
gulp.registry(new MyGulp());
Documentation
MyClass extends ClassyGulp {
this.defineTasks
Type: function
Return: Object
A function returning an Object of tasks to be registered. An Object of taskName: taskFunction
pairs.
example:
defineTasks() {
return {
scripts: this.scripts,
build: gulp.parallel(this.styles, 'scripts'),
watch: this.watch,
deploy: gulp.series('build'),
default: gulp.series('build', 'watch'),
};
}
}
Dependencies
Development
Just download the package and run
npm install
Built With
- undertaker-forward-reference - Enables to use gulp tasks before they're registered.
- undertaker-registry - The core which classy-gulp extends. A dependency of undertaker-forward-reference.
Contributing
- Javascript follows ESLint rules listed in the .eslintrc.json file.
- Feel free to fork the repo and make pull requests :)
Versioning
We use SemVer for versioning.
Authors
- UNCHAINED.studio - Initial work - https://unchained.studio
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details