1.1.0 • Published 6 years ago

gulp-collect-pattern v1.1.0

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

gulp-collect-pattern

Extract text by regular expression and collect it in a file with gulp.

Usage

Options

NameDescription
fileCollect the extracted text in this file.
streamWrite the extracted text to this stream.
regexExtract text matching this regular expression.
captureCollect text from capture group instead of entire match.

One of file or stream must be defined. regex is required.

Example

We could, for example, extract all inline style tags and collect the contents into an external css file.

var collect = require("gulp-collect-pattern")
var gulp = require("gulp")

gulp.task("html", function () {
  return gulp.src("*.html")
    .pipe(collect({
      file: "./dist/styles.css",
      regex: /<style>([\s\S]+?)<\/style>/g,
      capture: 1
    }))
    .pipe(gulp.dest("dist"))
})