我的配置会执行它应该执行的所有操作,但它永远不会刷新浏览器。一旦我手动刷新它,就会有变化。我正在连接到默认的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...
答案 0 :(得分:16)
我明白了:浏览器同步并不像隐式html标签,所以这(虽然有效的HTML5)不起作用:
<!doctype html>
<title>implicit</title>
但这会:
<!doctype html>
<html>
<head>
<title>full doc</title>
</head>
<body></body>
</html>