gruntjsbrowser-syncgrunt-contrib-watch

Gruntjs - Watch/Browsersync doesn't reload php


So I am using grunt to help me develop sites. For last two weeks I am having issues with Browsersync/Watch.

When I am making changes to a php files, browsersync doesn't detect any changes. Even, when I am reloading the site manually, source code is not updated. Most funny part is, this code gets updated after "some time" or when I am restarting grunt.

watch: {
    php: {
        files: ['*.php', '**/*.php'],
    }
},
// Run Browser Sync
browserSync: {
    default_options: {
        bsFiles: {
            src: [
                "**/*.php",
                "*.php",
            ]
        },
        options: {
            watchTask: true,
            proxy: 'g.test',
        }
    }
}

Does anyone had familiar issue?


Solution

  • Do you have a

     body 
    tag in your PHP files? Also, when running grunt, do you have a script (like one below) injected under body?

    <script id="__bs_script__">
    //<![CDATA[document.write("<script async src='/browser-sync/browser-sync-client.js?v=2.26.7'><\/script>".replace("HOST", location.hostname));
    //]]>
    </script>