Last active
July 7, 2016 22:28
-
-
Save PatrickJS/3ef9f9e6acf76f43a343 to your computer and use it in GitHub Desktop.
example browserify with watchify and gulp
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
var gulp = require('gulp'); | |
var livereload = require('tiny-lr'); | |
var server = livereload(); | |
var browserify = require('browserify'); | |
var ngannotate = require('browserify-ngannotate'); | |
var debowerify = require('debowerify'); | |
var uglifyify = require('uglifyify'); | |
var watchify = require('watchify'); | |
var source = require('vinyl-source-stream'); | |
var config = { | |
livereload: { | |
port: 35729 | |
}, | |
paths: { | |
scripts: [ | |
'app/*.js' | |
] | |
}, | |
build: { | |
path: 'public/build' | |
} | |
}; | |
gulp.task('browserify', function() { | |
var bundler = watchify(config.paths.script); | |
function gulpBundle() { | |
return bundler.bundle({ | |
// insertGlobals: true, | |
debug: true | |
}) | |
.pipe(source(config.build.scripts)) | |
.pipe(gulp.dest(config.build.path)) | |
.pipe(reload(server)); // if you have livereload | |
} | |
bundler | |
.transform(ngannotate) | |
.transform(uglifyify) | |
.transform(debowerify) | |
.on('update', gulpBundle); | |
return gulpBundle(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment