Last active
August 29, 2015 14:09
-
-
Save yuchuanxi/f294642a2546f56b7010 to your computer and use it in GitHub Desktop.
基于node环境,实现网页自动同步,服务自动重启 -- gulp+nodemon+browserSync+express
This file contains 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
/** | |
* | |
* @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