Parse build blocks in HTML to return a mapping from destination file to array of input files. Intended for use in combination with gulp-replace-build-block, gulp-filter and gulp-concat to provide useref like behaviour in gulp.
Inspired by the gulp-useref plugin, but with a signifigantly different design to provide greater modularity and streaming support.
npm install --save-dev html-build-blocks
The following example will parse HTML build blocks and use the returned map to create a gulp pipeline for concatination of those blocks. Note, this example doesn't order the files, they are concatenated in the order gulp loads them. To ensure ordering them simply add gulp-order to the pipeline.
var gulp =concat =filter =buildblocks = ;gulp;
Blocks are expressed as:
<!-- build:<type> <path> -->~ script tags or link tags ~<!-- endbuild -->
- type: either
- path: the file path of the optimized file, the target output
Takes a glob or array of globs. Returns a mapping of destination paths to arrays of source files.
buildblocks =='css/index.css': '/css/this.css' '/libs/that.css' ...'js/index.js': '/js/one_thing.js' '/libs/another_thing.js' ...'js/404.js': '/js/warning.js' ......
MIT © Nils Lundquist