Package Exports
- gulp-read
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 (gulp-read) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gulp-read
Gulp plugin to read vinyl file contents.
Installation
npm install --save-dev gulp-readUsage
Basically whenever you can get away with using read:false at the beginning of a stream, but you still need the file contents at a later stage. Here's what a typical example might look like:
var gulp = require('gulp');
var changed = require('gulp-changed');
var read = require('gulp-read');
var imagemin = require('gulp-imagemin');
var remember = require('gulp-remember');
gulp.task('image', function() {
return gulp.src('images/**', {read:false})
.pipe(changed('dist/images'))
.pipe(read())
.pipe(imagemin())
.pipe(remember())
.pipe(gulp.dest('dist/images'));
});In the above we don't have to read file contents initially since all gulp-changed cares about is the last modification date of each file.
After the unchanged files have been removed from the stream the contents of the remaining files are then read by gulp-read so they can be processed by gulp-imagemin.
In effect we never have to read the contents of files that haven't changed which saves time and speeds up the build.
Compatibiliy
Since this plugin is basically identical to the get-contents module of vinyl-fs it shouldn't make a difference whether file contents are read by gulp.src() or gulp-read.
API
read([options])
Reads the contents for each vinyl file from disk.
Options
buffer: Whether or not the file contents should be aBuffer. Setting this tofalsewill makefile.contentsa stream. (Default:true)force: Whether or not to reread file contents if they already exist. (Default:false)stripBOM: Whether or not to strip the BOM from file contents. (Default:true)