Last active
January 2, 2016 23:43
-
-
Save georgeteo/3e7bdf2011bc693be94a to your computer and use it in GitHub Desktop.
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'); | |
var source = require('vinyl-source-stream'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var reactify = require('reactify'); | |
var path = { | |
HTML: 'src/index.html', | |
OUT: 'build.js', | |
DEST: 'dist', | |
DEST_SRC: 'dist/src', | |
ENTRY_POINT: './src/js/main.js' | |
}; | |
gulp.task('copy', function(){ | |
gulp.src(path.HTML) | |
.pipe(gulp.dest(path.DEST)); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(path.HTML, ['copy']); | |
var watcher = watchify(browserify({ | |
entries: [path.ENTRY_POINT], | |
transform: [reactify], | |
debug: true, | |
cache: {}, packageCache: {}, fullPaths: true | |
})); | |
return watcher.on('update', function () { | |
watcher.bundle() | |
.pipe(source(path.OUT)) | |
.pipe(gulp.dest(path.DEST_SRC)) | |
console.log('Updated'); | |
}) | |
.bundle() | |
.pipe(source(path.OUT)) | |
.pipe(gulp.dest(path.DEST_SRC)); | |
}); | |
gulp.task('default', ['watch']); | |
/* Deprecated Version | |
gulp.task('browserify', function() { | |
gulp.src('src/js/main.js') | |
.pipe(browserify({transform:'reactify'})) | |
.pipe(concat('main.js')) | |
.pipe(gulp.dest('dist/js')); | |
}); | |
gulp.task('copy', function() { | |
gulp.src('src/index.html') | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('default',['browserify', 'copy']); | |
*/ | |
//gulp.task('watch', function() { | |
// gulp.watch('src/**/*.*', ['default']); | |
//}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment