Skip to content

Instantly share code, notes, and snippets.

@wailorman
Last active November 2, 2015 23:55
Show Gist options
  • Save wailorman/cb744cc07f05c3275c8d to your computer and use it in GitHub Desktop.
Save wailorman/cb744cc07f05c3275c8d to your computer and use it in GitHub Desktop.
JSX gulp watch + browserify + babelify + livereload
var gulp = require('gulp'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
babelify = require('babelify'),
gulpLiveReload = require('gulp-livereload');
gulp.task('scripts', function () {
//noinspection JSUnresolvedFunction
return browserify('src/main.js', {debug: true}) // browserify entry file
.transform(babelify, {presets: ['es2015', 'react']})
.bundle()
.pipe(source('bundle.js')
.pipe(gulp.dest('build'))
.pipe(gulpLiveReload());
});
gulp.task('livereload-server', function () {
gulpLiveReload.listen({}, function () {
console.log('Live Reload server ... OK');
});
});
gulp.task('watch', ['scripts', 'livereload-server'], function () {
gulp.watch('src/**/*.js', ['scripts']);
});
{
"devDependencies": {
"babel-preset-es2015": "^6.0.14",
"babel-preset-react": "^6.0.14",
"babelify": "^7.0.2",
"browserify": "^12.0.1",
"gulp": "^3.9.0",
"gulp-livereload": "^3.8.1",
"vinyl-source-stream": "^1.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment