JSPM

assemble-handle

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37835
  • Score
    100M100P100Q153783F
  • License MIT

Assemble pipeline plugin for handling custom middleware stages.

Package Exports

  • assemble-handle

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (assemble-handle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

assemble-handle NPM version NPM downloads Build Status

Assemble pipeline plugin for handling custom middleware stages.

Install

Install with npm:

$ npm install assemble-handle --save

Usage

var assemble = require('assemble');
var handle = require('assemble-handle');
var app = assemble();

app.onStream(/\.(js|css)$/, function(file, next) {
  // lint javascript
  file.dirname = path.join(file.dirname, file.extname);
  next();
});

app.preWrite(/\.(jpg|png)$/, function(file, next) {
  // minify images
  next();
});

app.postWrite(/some\/junk/, function(file, next) {
  // delete junk
  next();
});

app.task('site', function() {
  return app.src('assets/**/*.*')
    .pipe(handle(app, 'onStream'))  // onStream
    .pipe(handle(app, 'preWrite'))  // preWrite
    .pipe(app.dest('site/'));
    .pipe(handle(app, 'postWrite')) // postWrite
});

Custom handlers

Create custom middleware handlers.

app.handler('onFoo');

This adds an .onFoo method to the instance:

app.onFoo(/\.hbs$/, function(file, next) {
  // do stuff to file
  next();
});

All .onFoo middleware will now run when the onFoo handler is called:

app.task('default', function() {
  return app.src('*.hbs')

    // call the `onFoo` handler
    .pipe(handle(app, 'onFoo')) 
});

You might also be interested in these projects:

  • assemble-core: The core assemble application with no presets or defaults. All configuration is left to the… more | homepage
  • assemble-fs: Assemble plugin to add methods to assemble for working with the file system, like src,… more | homepage
  • assemble-streams: Assemble pipeline plugin for pushing a view collection into a vinyl stream. | homepage
  • assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage

Contributing

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

Building docs

Generate readme and API documentation with [verb][]:

$ npm install verb && npm run docs

Or, if [verb][] is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on May 17, 2016.