0

I'm using gulp.js and BrowserSync. When I save the CSS files no changes have been made. No problem with HTML files. And I'm not using LESS or SASS. I'm using pure CSS. The code for my gulp.js file is below:

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

gulp.task('serve', function() {
    browserSync.init({
        server: "./"
    });
    gulp.watch(["./*.html", "./css/*.css"]).on('change', browserSync.reload);
});

gulp.task('default', ['serve']);

1 Answer 1

1
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;

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

  gulp.watch(['*.html', 'css/*.css'], {cwd: './'}, reload);
});

gulp.task('default', ['serve']);

Can you tryout this one it looks like you are configuring a basedir from your current directory and also include this in the watcher. I prefer using a dir name instead of ./ normally people use app as baseDir.

Sign up to request clarification or add additional context in comments.

1 Comment

@PirateofMarmara No problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.