Grunt browser sync not pushing changes

I am trying to get grunt-browser-sync to insert any css changes into the open browser when the file is updated / modified. But for some reason, I can make it work, and grunting does not give me any errors so that I know that this does not work.

I am currently using MAMP as it is a Wordpress based project.

Here is my Gruntfile.js:

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
  build: {
    src: '_/js/libs/*.js', //input
    dest: '_/js/functions.min.js' //output
  }
},
sass: {
  dist: {
    options: {
      loadPath: require('node-bourbon').includePaths,
      loadPath: require('node-neat').includePaths,
      style: 'compressed'
    },
    files: {
      'style.css': 'scss/style.scss'
    }
  }
},

autoprefixer: {
dist: {
  files: {
    'style.css': 'style.css'
  }
 }
},
browserSync: {
        dev: {
            bsFiles: {
                src : 'style.css'
            },
            options: {
                watchTask: true
            }
        }
    },

watch: {
  options: {
    livereload: true
},
js: {
files: ["_/js/libs/*.js"],
tasks: ["ugilify"],
},
sass: {
files: ["scss/*.scss"],
tasks: ["sass", "autoprefixer", "browserSync"],
},
php: {
files: ['*.php']
  },
 }
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-browser-sync');

// Default task(s).
grunt.registerTask('default', ['uglify', 'sass', 'browserSync', 'watch', 'autoprefixer']);

};

and here is the output when I save / update the file:

Running "watch" task
Waiting...
>> File "scss/global.scss" changed.
Running "sass:dist" (sass) task
File style.css created.

Running "autoprefixer:dist" (autoprefixer) task
File style.css created.

Running "browserSync:dev" (browserSync) task

Done, without errors.
Completed in 1.478s at Wed May 07 2014 18:47:40 GMT-0500 (CDT) - Waiting...

But then I have to physically refresh the browser to see the changes.

I'm not sure if I have something missing in the grunt file or what.

+4
source share
2 answers

grunt-, , - 1.9.1. ,

npm install grunt-browser-sync@1.9.1 --save-dev
+1

Source: https://habr.com/ru/post/1539678/


All Articles