1.0.1 • Published 6 years ago

classy-gulp v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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

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

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