event (required when server.notify is invoked without pipe) - Object - Event object that is normally passed to gulp.watch callback.
Should contain path property with changed file path.
Usage
// gulpfile.jsvargulp=require('gulp');varserver=require('gulp-express');gulp.task('server',function(){// Start the server at the beginning of the taskserver.run(['app.js']);// Restart the server when file changesgulp.watch(['app/**/*.html'],server.notify);gulp.watch(['app/styles/**/*.scss'],['styles:scss']);//gulp.watch(['{.tmp,app}/styles/**/*.css'], ['styles:css', server.notify]);//Event object won't pass down to gulp.watch's callback if there's more than one of them.//So the correct way to use server.notify is as following:gulp.watch(['{.tmp,app}/styles/**/*.css'],function(event){gulp.run('styles:css');server.notify(event);//pipe support is added for server.notify since v0.1.5,//see https://github.com/gimm/gulp-express#servernotifyevent});gulp.watch(['app/scripts/**/*.js'],['jshint']);gulp.watch(['app/images/**/*'],server.notify);gulp.watch(['app.js','routes/**/*.js'],[server.run]);});
// app.jsvarexpress=require('express');varapp=module.exports.app=exports.app=express();//you won't need 'connect-livereload' if you have livereload plugin for your browserapp.use(require('connect-livereload')());
请发表评论