In my gulp.js file I'm streaming all HTML files from the examples
folder into the build
folder.
To create the gulp task is not difficult:
var gulp = require('gulp'); gulp.task('examples', function() { return gulp.src('./examples/*.html') .pipe(gulp.dest('./build')); });
But I can't figure out how retrieve the file names found (and processed) in the task, or I can't find the right plugin.
The src() and dest() methods are exposed by gulp to interact with files on your computer. src() is given a glob to read from the file system and produces a Node stream. It locates all matching files and reads them into memory to pass through the stream.
Gulp is a task runner that uses Node. js as a platform. Gulp purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. It builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.
I'm not sure how you want to use the file names, but one of these should help:
If you just want to see the names, you can use something like gulp-debug
, which lists the details of the vinyl file. Insert this anywhere you want a list, like so:
var gulp = require('gulp'), debug = require('gulp-debug'); gulp.task('examples', function() { return gulp.src('./examples/*.html') .pipe(debug()) .pipe(gulp.dest('./build')); });
Another option is gulp-filelog
, which I haven't used, but sounds similar (it might be a bit cleaner).
Another options is gulp-filesize
, which outputs both the file and it's size.
If you want more control, you can use something like gulp-tap
, which lets you provide your own function and look at the files in the pipe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With