-
-
Save McNull/6f9817be7f4b90adb86b79bf8f3d3914 to your computer and use it in GitHub Desktop.
Simple babel livereload
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'), | |
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']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment