无法设置我的gulp + livereload服务器以重新启动并更新JS文件的更改页面。我怎么能实现它?
这是我的gulpfile.js:
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
watch = require('gulp-watch'),
express = require('express'),
app = express(),
path = require('path'),
server = tinylr();
...
gulp.task('js', function() {
return gulp.src([
'app/scripts/*.js',
])
.pipe( concat('combined.js'))
.pipe( gulp.dest('../dist/app/js/'))
.pipe( livereload( server ));
});
gulp.task('watch', function () {
...
gulp.watch(['app/scripts/*.js'],['js']);
});
答案 0 :(得分:0)
使用livereload.reload()而不是livereload(),不要忘记安装浏览器扩展并将livereload脚本添加到你的页面(使用src =" // localhost:35729 / livereload.js? snipver = 1"默认情况下)