Gio*_*ini 0 javascript gulp browser-sync
Browsersync只是重新加载index.html,即使我有我的基础设置,甚至文件选项上列出的特定文件.
我已查看他们的文档,但我有他们说的所有内容,仍然只刷新或同步index.hrml,但about.html例如没有.
我的结构是这样的:
-booming-gaes-web
-dist
-node_modules
-src
-index.html
-about.html
-gulpfile.js
Run Code Online (Sandbox Code Playgroud)
所以我的html文件在我的src文件夹上是直接的,并且gulp文件与src文件夹在同一个文件夹中.
我的gulp档案:
// Include gulp
var gulp = require('gulp');
// Include Plugins
var browserSync = require('browser-sync');
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('src/js/*.js', ['js-watch']);
gulp.watch('src/css/*.scss', ['sass-watch']);
gulp.watch('src/css/*.css', ['prefix']);
gulp.watch('src/*.html').on('change', browserSync.reload);
browserSync({
files: ['src/index.html','about.html'],
server:{
baseDir:'src',
directory: true
}
});
});
Run Code Online (Sandbox Code Playgroud)
我做错了什么想法?谢谢!
我刚刚发现...
我的关于页面没有body标签,browsersync需要它有一个body标签才能工作.
从他们的帮助:
99%的情况下,这是因为您的网页没有正文标记.为了使Browsersync正确连接,您的网站中必须存在正文标记(我们在其后面添加一个脚本标记).