Last active
August 29, 2015 14:10
-
-
Save szmeku/e8a3ab9b4e1b4bf3ecae 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
'use strict'; | |
var gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
source = require('vinyl-source-stream'), | |
browserify = require('browserify'), | |
debowerify = require('debowerify'), | |
watchify = require('watchify'); | |
var distPath = './dist'; | |
gulp.task('bundler-watch', function () { | |
var bundler = watchify(browserify('./src/main.js', {debug: true}).transform(debowerify)); | |
bundler.on("log", function (msg) { | |
gutil.log(gutil.colors.green(msg)); | |
}); | |
bundler.on('update', rebundle); | |
function rebundle(file) { | |
if (file) { | |
file.map(function (fileName) { | |
gutil.log('File updated', gutil.colors.blue(fileName)); | |
}); | |
} | |
return bundler | |
.bundle() | |
.on("error", function (err) { | |
gutil.log("Browserify error:", err); | |
}) | |
.pipe(source('bundle.js')) | |
.pipe(gulp.dest(distPath)); | |
} | |
rebundle(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment