Tab
Tab

Reputation: 55

the browser wont reload automatic,but will once I click somewhere,eg, the browser irself

This is weird to get this problem, and after some search, I cant fix this problem, This is my first time to ask something on stackoverflow. my gulpfile.js following...

//I just want an easy task,once the css change,reload the browser.
var gulp = require('gulp');
var browserSync = require('browser-sync');
gulp.task('watch',['browserSync'], function() {
      gulp.watch('src/css/*.css', browserSycn.reload);
      gulp.watch('src/*.html', browserSync.reload);
});

gulp.task('browserSync', function() {
      browserSync({
           server: {
              baseDir: 'src'
              }
        })
    });

Thank you guys!

Upvotes: 1

Views: 87

Answers (1)

Mr. Baudin
Mr. Baudin

Reputation: 2254

Normally you would use:

var browserSync = require('browser-sync').create();

And use

browserSync.**init**({
       server: {
          baseDir: 'src'
          }
    })

To initialize. Hope this helps.

EDIT 17 jan 2016: WebStorm can sometimes seem to cache the change and not write it to the file system. In this case browserSync (gulp) can't see the change. Clicking out of WebStorm or refreshing will force the update. This seems to be your problem.

Upvotes: 1

Related Questions