简体   繁体   English

Gulp保存文件时浏览器同步刷新ATOM编辑器?

[英]Gulp browser-sync refreshing ATOM editor on file save?

I have the following gulp file setup for testing purposes of small ideas etc.. 我有以下gulp文件设置用于测试小主意等。

My project is setup the following way 我的项目按以下方式设置

  • Project 项目
    • site 现场
      • CSS CSS
      • img IMG
      • js JS
      • index.html 的index.html
    • gulpfile.js gulpfile.js
    • package.json 的package.json

Every time a save a html, css, or js from the site directory, instead of my browser refreshing, my atom text editor refreshes. 每当a从site目录中保存html, css, or js ,我的原子文本编辑器都会刷新,而不是刷新浏览器。 Its kind of annoying. 有点烦人。 I have other projects setup similarly but they are work just fine. 我也有类似的其他项目设置,但它们工作正常。 its just this one i can't seem to figure out. 它只是我似乎无法弄清楚的那个。

is it my code, or something else? 是我的代码,还是其他?

 var gulp = require('gulp'), bs = require('browser-sync').create(), sequence = require('run-sequence'); gulp.task('styles', function() { gulp.src('site/css/*.css') .pipe(gulp.dest('site/css')) .pipe(bs.stream()); }); gulp.task('js', function() { gulp.src(['site/js/*.js']) // .pipe(concat('all.js')) .pipe(gulp.dest('site/js')) .pipe(bs.stream()); }); gulp.task('html', function() { gulp.src('site/*.html') .pipe(gulp.dest('site/')) .pipe(bs.stream()); }); gulp.task('browser-sync', function() { bs.init({ server: 'site' }); }); gulp.task('watch', ['build'], function() { gulp.watch(['site/css/*.css'], ['styles']); gulp.watch(['site/js/*.js'], ['js']); gulp.watch(['site/*.html'], ['html']); }); gulp.task('build', function(done) { sequence( ['html', 'js', 'styles'], 'browser-sync', done); }); gulp.task('default', ['watch']); 

The issue was that I didn't have a body tag in my index file. 问题是我的索引文件中没有body标签。 Once I added it, atom stopped refreshing and browser-sync started working properly 添加后,atom停止刷新,并且浏览器同步开始正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM