Skip to content

Instantly share code, notes, and snippets.

@cdekok
Created February 23, 2015 18:27
Show Gist options
  • Save cdekok/2fb3be27652dde7f5b39 to your computer and use it in GitHub Desktop.
Save cdekok/2fb3be27652dde7f5b39 to your computer and use it in GitHub Desktop.
"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