Created
May 12, 2014 19:53
-
-
Save jshbrntt/08b726b7dce29f685356 to your computer and use it in GitHub Desktop.
Gulp + Watchify + Debowerify + Uglify
This file contains hidden or 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
/* global require */ | |
var gulp = require('gulp'); | |
var browserify = require('browserify'); | |
var sync = require('browser-sync'); | |
var source = require('vinyl-source-stream'); | |
var uglify = require('gulp-uglify'); | |
var plumber = require('gulp-plumber'); | |
var streamify = require('gulp-streamify'); | |
var watchify = require('watchify'); | |
gulp.task('sync', ['scripts'], function() { | |
sync.init(null, { | |
server: { | |
baseDir: "./www" | |
} | |
}); | |
}); | |
gulp.task('scripts', function () { | |
var bundler = watchify('./src/scripts/main'); | |
bundler.transform('debowerify'); | |
bundler.on('update', rebundle); | |
function rebundle () { | |
return bundler.bundle() | |
.pipe(source('bundle.js')) | |
.pipe(streamify(uglify())) | |
.pipe(gulp.dest('www/scripts')) | |
.pipe(sync.reload({stream:true, once: true})); | |
} | |
return rebundle(); | |
}); | |
gulp.task('default', ['sync'], function () { | |
gulp.watch("./src/scripts/**/*.js", ['scripts']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment