Awesome
gulp-routes
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
enRoute
{Object}: Instance of en-route.returns
{Function}
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
method
{String}: Method to run middleware.returns
{Stream}: Returns a stream for piping files through.
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:
- base-routes: Plugin for adding routes support to your
base
application. Requires templates support to work. | homepage - base: Framework for rapidly creating high quality node.js applications, using plugins like building blocks | homepage
- en-route: Routing for static site generators, build systems and task runners, heavily based on express.js routes… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Contributors
Commits | Contributor |
---|---|
6 | jonschlinkert |
5 | doowb |
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.