[英]Browser-sync (under gulp) doesn't refresh browser
我的配置完成了它應該做的一切,但它永遠不會刷新瀏覽器。 一旦我手動刷新它,就會有變化。 我正在連接到默認的localhost:3000。 任何想法為什么會這樣或如何調試它?
gulpfile.js:
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
gulp.task('html', function () {
browserSync.reload();
});
gulp.task('sass', function() {
return gulp.src('./app/scss/style.scss')
.pipe(sass())
.pipe(gulp.dest('./app/css'))
.pipe(browserSync.reload({ stream:true }));
});
gulp.task('serve', function() {
browserSync({
server: {
baseDir: 'app'
}
});
});
gulp.task('default', ['serve'], function () {
gulp.watch('./app/scss/*.scss', ['sass', browserSync.reload]);
gulp.watch('./app/*.html', ['html', browserSync.reload]);
});
控制台輸出的示例:
[BS] Local URL: http://localhost:3000
[BS] External URL: http://192.168.1.3:3000
[BS] Serving files from: app
[17:10:32] Starting 'html'...
[BS] Reloading Browsers...
[17:10:32] Finished 'html' after 829 μs
[BS] Reloading Browsers...
[17:10:42] Starting 'sass'...
[BS] 1 file changed (style.css)
[17:10:42] Finished 'sass' after 22 ms
[BS] Reloading Browsers...
[17:11:02] Starting 'html'...
[BS] Reloading Browsers...
[17:11:02] Finished 'html' after 472 μs
[BS] Reloading Browsers...
我明白了:瀏覽器同步不喜歡隱式的html標簽,所以這(雖然有效的HTML5)不起作用:
<!doctype html>
<title>implicit</title>
但這會:
<!doctype html>
<html>
<head>
<title>full doc</title>
</head>
<body></body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.