【发布时间】:2016-07-27 21:19:35
【问题描述】:
我正在尝试使用 gulp 使用快速服务器进行实时重新加载
但是 gulp 运行后退出如下,无法访问服务器
cmd 输出:
D:\Users\workspace\server>gulp 服务器 [11:31:56] 使用 gulpfile D:\Users\workspace\server\gulpfile.js
[11:31:56] 正在启动“服务器”...
[11:31:56] 26 毫秒后完成“服务器”
livereload[tiny-lr] 正在监听 35729 ...
D:\Users\workspace\server>
gulpfile.js:
var gulp = require('gulp');
var server = require('gulp-express');
gulp.task('server', function () {
// Start the server at the beginning of the task
server.run(['app.js']);
// Restart the server when file changes
gulp.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]);
});
gulp.task('default', ['server']);
我调用 gulp 的方式有什么根本不正确的地方吗?
【问题讨论】:
-
gulp-express已被弃用,并且已经一年没有维护了。请改用gulp-live-server。 -
实时重载是什么意思?
标签: node.js express gulp livereload gulp-watch