Grunt browser-sync not watching php file changes in WordPress

I’ve set up grunt successfully to watch sass and js file changes in my Gruntfile.js. The only thing its not picking up are the changes to my php files. Looking at the documentation for browser-sync for Wrodpress, i need to state options like so:

    browserSync: {
        files: {
            src : [
                'style.css',
                'images/*',
                'js/**/*.js',
                '**/*.php'
            ],
        },
        options: {
            // server: {
              //  host: "192.168.1.141:8888/bch",
               // baseDir: "/", // "./",
           // },
            proxy: "localhost",
           // port: 8888,
            watchTask: true
        } 
    }

I’ve tried the commented out options aswell as a slightly differnt sytax setup at http://www.browsersync.io/docs/grunt/ at the bottom of the page and for any option neither does the grunt-cli show any updates nor does the browser change on save. Is there an obvious component I’m missing?

Related posts

Leave a Reply

1 comment

  1. For anyone fairly new to this as I am and wanted to know what i did:

        browserSync: {
            dev: {
                options: {
                    proxy: "localhost:8888",
                    files: ['style.css', 'js/**/*.js', '**/*.php'],
                    watchTask: true, 
                }
            }
        }
    
    1. Stating the port explicitly as per my quesiton example meant the browser sync wouldn’t go to its default :3000 port for it to then run its sync magic
    2. Although it does need a reference to the 8888 as its part of my base local URL. So instead i put it in the proxy: option and i can click through to any project from there in my htdocs folder.
    3. Wrapping it in dev: {} to tell browser-sync i had my own server running (MAMP)
    4. This also then stopped the annoying error of Fate Error: not running when trying to come out of the currently running ‘grunt’ command.

    On Mac OSX Mavericks, with MAMP.