Last active
August 29, 2015 14:04
-
-
Save dhoko/d28f6e655b9c34696bb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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