gulp-query-selector

0.2.31 • Public • Published

gulp-query-selector

Build Status Dependency Status devDependency Status NPM version

Selects DOM nodes from Node.js streams and packs selected code into separated streams.

Usage

First, install gulp-query-selector as a development dependency:

npm install --save-dev gulp-query-selector

Then, add it to your gulpfile.js:

var querySelector = require("gulp-query-selector");
var inject = require("gulp-inject");
 
gulp.task("make-html", function(){
  var partials = gulp.src("pages/*.html")
    .pipe(querySelector("body > *"))
    .pipe(querySelector.groupBySource());
  return gulp.src("index.html")
    .pipe(inject(partials), {
      starttag: '<!-- inject:partials -->',
      transform: function (filePath, file) { return file.contents.toString('utf8'); }
    })
    .pipe(gulp.dest("./dist"));
});

Above example is pretty complicated, but it's the simplest one I've been able to come up with. It selects contents of <body> elements from all HTML files found in pages forlder, and then injects these contents to another HTML code using gulp-inject plugin.

License

Copyright © 2015 - 2019 Maciej Chałapuk. Released under MIT License.

Package Sidebar

Install

npm i gulp-query-selector

Weekly Downloads

1

Version

0.2.31

License

MIT

Unpacked Size

10.3 kB

Total Files

9

Last publish

Collaborators

  • mchalapuk