Skip to content

Instantly share code, notes, and snippets.

@dhoko
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhoko/d28f6e655b9c34696bb6 to your computer and use it in GitHub Desktop.
Save dhoko/d28f6e655b9c34696bb6 to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
gutil = require('gulp-util'),
watchify = require("watchify"),
concat = require("gulp-concat"),
streamqueue = require('streamqueue'),
streamify = require('gulp-streamify'),
source = require('vinyl-source-stream'),
livereload = require('gulp-livereload');
/**
* Create a single file app.js
*/
module.exports = function(server, templates) {
// Concatenate your app and build an app.js
var bundler = watchify('./src/scripts/core/core.js');
bundler.on('update',rebundle);
function rebundle(file) {
if(file) {
file.forEach(function (fileName) {
gutil.log('File updated', gutil.colors.yellow(fileName));
});
}
var stream = streamqueue({objectMode: true});
stream.queue(templates());
stream.queue(bundler
.bundle({
debug: (gutil.env.type !== 'prod')
})
.on("error", function(err) {
gutil.log("Browserify error:", err);
})
.pipe(source("app.js")));
return stream.done()
.pipe(streamify(concat('app.js')))
.pipe(gulp.dest('./app/js'))
.pipe(livereload(server));
}
return rebundle();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment