From b9aea5b5acc85defbddf6c8384464a3df707a365 Mon Sep 17 00:00:00 2001 From: Joakim Bengtson Date: Thu, 13 Feb 2014 19:22:11 +0100 Subject: [PATCH] Bumping version and readme --- README.md | 36 ++++++++++++++++++++++++++++++------ package.json | 7 ++++--- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 91bcb21..3898052 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,33 @@ npm install --save-dev gulp-inject Then, add it to your `gulpfile.js`: +### Mode 1: Given a Vinyl File Stream + +**Note:** New from `v.0.3`. Here you pipe `inject` through *where* to inject. + +```javascript +var inject = require("gulp-inject"); + +gulp.src('./src/index.html') + .pipe(inject(gulp.src(["./src/*.js", "./src/*.css"], {read: false})) // Not necessary to read the files (will speed up things), we're only after their paths + .pipe(gulp.dest("./dist")); +``` + +### Mode 2: Given a path to html template + +**Note:** Old behavior. Here you pipe `inject` through *what* to inject. + ```javascript var inject = require("gulp-inject"); -gulp.src("./src/*.ext", {read: false}) // Not necessary to read the files (will speed up things), we're only after their paths +gulp.src(["./src/*.js", "./src/*.css"], {read: false}) // Not necessary to read the files (will speed up things), we're only after their paths .pipe(inject("path/to/your/index.html")) .pipe(gulp.dest("./dist")); ``` + +### Template contents (regarding of mode above) + Add injection tags to your `index.html`: ```html @@ -45,13 +64,18 @@ Add injection tags to your `index.html`: ## API -### inject(filename, options) +### inject(fileOrStream, options) -#### filename -Type: `String` +#### fileOrStream +Type: `Stream` or `String` + +**If `Stream`** + +Since `v.0.3` you can provide a Vinyl File Stream as input to `inject`, see Mode 1 in the example above. +**If `String`** -Path to template file (where your injection tags are). Is also used as filename for the plugin's output file. +Can also be a path to the template file (where your injection tags are). Is also used as filename for the plugin's output file. #### options.templateString Type: `String` @@ -59,7 +83,7 @@ Type: `String` Default: `NULL` -Is used as template instead of the contents of given `filename`. +Is used as template instead of the contents of given `filename`. (Only used if `fileOrStream` is a `String`) #### options.ignorePath Type: `String` or `Array` diff --git a/package.json b/package.json index 2efa57a..a12e3d6 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "gulp-inject", - "version": "0.2.2", - "description": "A javascript, stylesheet and webcomponent injection plugin for Gulp", + "version": "0.3.0", + "description": "A javascript, stylesheet and webcomponent injection plugin for Gulp, i.e. inject file references into your index.html", "keywords": [ "gulpplugin", "inject", "stylesheets", + "webcomponents", "scripts", "index" ], @@ -26,7 +27,7 @@ }, "dependencies": { "gulp-util": "~2.2.0", - "through": "~2.3.4" + "event-stream": "~3.1.0" }, "devDependencies": { "mocha": "~1.17.0",