Skip to content

Instantly share code, notes, and snippets.

@sudodoki
Created December 14, 2014 18:20
Show Gist options
  • Save sudodoki/c772340145fb4ef65fe1 to your computer and use it in GitHub Desktop.
Save sudodoki/c772340145fb4ef65fe1 to your computer and use it in GitHub Desktop.
Adds a list of files in resulting concatenated file
var gulp = require('gulp');
var concat = require('gulp-concat-util');
var through = require('through');
var gutil = require('gulp-util');
var refObj = {wallOfText: ''};
function write(file) {
refObj.wallOfText += "/* " + file.path + " */" + gutil.linefeed;
this.emit('data', file);
}
function end() {
this.emit('end');
}
gulp.task('scripts', function() {
gulp.src('./src/*.js')
.pipe(through(write, end))
.pipe(concat('all.js'))
.pipe(concat.header('/* Files concatenated for this file:*/\n<%= refObj.wallOfText %>\n', {refObj: refObj}))
.pipe(gulp.dest('./dist/'))
});
gulp.task('default', ['scripts']);
@sudodoki
Copy link
Author

Instead of full path, you can have it to be relative, just use path.relative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment