Created
February 23, 2015 18:27
-
-
Save cdekok/2fb3be27652dde7f5b39 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'); | |
var gutil = require('gulp-util'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var source = require('vinyl-source-stream'); | |
var buffer = require('vinyl-buffer'); | |
var watchify = require('watchify'); | |
var browserify = require('browserify'); | |
var livereload = require('gulp-livereload'); | |
var to5 = require('gulp-6to5'); | |
var bundler = watchify(browserify( | |
'./src/mediabank.js', watchify.args | |
)); | |
// add any other browserify options or transforms here | |
bundler.transform('reactify'); | |
bundler.on('update', bundle); // on any dep update, runs the bundler | |
function bundle() { | |
livereload.listen(); | |
return bundler.bundle() | |
// log errors if they happen | |
.on('error', | |
gutil.log.bind(gutil, 'Browserify Error' | |
)) | |
.pipe(source('bundle.js')) | |
.pipe(buffer()) | |
.pipe(to5()) | |
.pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file | |
.pipe(sourcemaps.write('./')) // writes .map file | |
.pipe(gulp.dest('./../php-app/js/')) | |
.pipe(livereload()); | |
} | |
gulp.task('watch', bundle); | |
gulp.task('default', ['watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment