Skip to content

Instantly share code, notes, and snippets.

@yuchuanxi
Last active August 29, 2015 14:09
Show Gist options
  • Save yuchuanxi/f294642a2546f56b7010 to your computer and use it in GitHub Desktop.
Save yuchuanxi/f294642a2546f56b7010 to your computer and use it in GitHub Desktop.
基于node环境,实现网页自动同步,服务自动重启 -- gulp+nodemon+browserSync+express
/**
*
* @authors gooofly (QQ941721234, wangfei.f2e@gmail.com, http://www.gooofly.com)
* @date 2014-11-17 21:37:36
* @version $Id$
*
* title
* --------------------------------------------
*/
var
gulp = require('gulp'),
debug = require('debug')('gf:gulpfile'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
nodemon = require('gulp-nodemon');
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
proxy: {
host: 'http://localhost',
port: 5000
}
});
});
gulp.task('default', ['browser-sync'], function() {
gulp.watch(['./public/**/*.js', './views/*.hbs'], reload);
});
gulp.task('nodemon', function(cb) {
var called = false;
return nodemon({
script: './bin/www',
ext: 'js',
ignore: ['./public/**'],
nodeArgs: ['--debug']
}).on('start', function() {
if (!called) {
called = true;
cb();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment