0
我爲我的開發服務器使用gulp-connect
插件,並且我還安裝了gulp-livereload
。然後,我做了以下工作:Gulp livereload無法與使用手錶的gulp連接配合使用
var gulp = require('gulp'),
connect = require('gulp-connect'),
livereload = require('gulp-livereload');
gulp.task('serve', function() {
connect.server({
root: 'app',
livereload: true
});
});
gulp.task('css', function() {
gulp.src('./app/stylesheets/*.css')
.pipe(connect.reload());
});
gulp.task('html', function() {
gulp.src('./app/index.html')
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('./app/stylesheets/*.css', ['css']);
gulp.watch('./app/index.html', ['html']);
});
gulp.task('default', ['serve', 'watch']);
但每當我運行的服務器,並以樣式表或index.html
任何改變,我仍然需要手動刷新頁面,雖然我已經根據自己的文檔做的一切。我也試過寫這樣的default
任務:
gulp.task('default', ['serve', 'html', 'css', 'watch']);
但它也沒有幫助。 livereload有什麼問題?
添加:當我檢查控制檯時,它說它無法連接到ws://localhost:35729/livereload
。另外,當我刷新頁面時,控制檯表示與ws://localhost:35729/livereload
的連接中斷。這是否意味着livereload無法建立正確的連接?
編輯:雖然我什麼都沒做,現在livereload自動刷新頁面,當我改變我的.css
文件。但是當我更改index.html
時它仍然不刷新。