Skip to content

Instantly share code, notes, and snippets.

@grifdail
Last active June 5, 2018 13:35
Show Gist options
  • Save grifdail/04d6ec019275f4bea3c8 to your computer and use it in GitHub Desktop.
Save grifdail/04d6ec019275f4bea3c8 to your computer and use it in GitHub Desktop.
Simple babel livereload
var gulp = require('gulp'),
babel = require('gulp-babel'),
livereload = require('gulp-livereload'),
http = require('http'),
st = require('st'),
transform = require('vinyl-transform'),
browserify = require('browserify');
gulp.task('js', ["es6"],function() {
var browserified = transform(function(filename) {
var b = browserify({entries: filename, debug: true, basedir:"./build"});
return b.bundle();
});
return gulp.src("build/main.js")
.pipe(browserified)
.pipe(gulp.dest("./"))
.pipe(livereload());
});
gulp.task("es6",function() {
return gulp.src("src/**/*.js")
.pipe(babel())
.pipe(gulp.dest("build"));
});
gulp.task("default",["js"],function(done) {
http.createServer(
st({ index: 'index.html', cache: false, path: __dirname })
).listen(8080, done);
livereload.listen();
gulp.watch('src/*', ['js']);
});
@aaronhuckabee
Copy link

Thanks! Found this helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment