Home

Awesome

gulp-routes NPM version NPM monthly downloads NPM total downloads Linux Build Status

Add middleware to run for specified routes in your gulp pipeline.

Install

Install with npm:

$ npm install --save gulp-routes

Usage

routes

The main export is a function that takes an instance of en-route and returns a gulp plugin function.

Params

Example

var routes = require('gulp-routes');
var Router = require('en-route').Router;
var router = new Router();

// define middleware
router.all(/\.hbs/, function (file, next) {
  var str = file.contents.toString();
  // do anything to `file` that can be done
  // in a gulp plugin
  file.contents = new Buffer(str);
  next();
});

// pass the router to `gulp-routes`
var route = routes(router);

gulp.src('*.hbs')
  .pipe(route())
  .pipe(gulp.dest('_gh_pages/'));

route

Create a router stream to run middleware for the specified method.

Params

Example

gulp.src('*.hbs')
  .pipe(route('before'))
  .pipe(otherPlugin())
  .pipe(route('after'))
  .pipe(gulp.dest('dist/'));

About

Related projects

You might also be interested in these projects:

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

CommitsContributor
6jonschlinkert
5doowb

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Brian Woodward

License

Copyright © 2017, Brian Woodward. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on August 07, 2017.