Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 watch blade files with browserSync

In laravel 5.4 mix and browserSync are coming by default. I want to get my browser refreshed with new changes if I modify any *.blade.php files from resources/views. In my webpack.mix.jsI have got this configuration:

const { mix } = require('laravel-mix');

mix
    .js('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css')
    .browserSync({
        proxy:'localhost',
        port:8000,
        files: {
            match: [
                "resources/views/**/*.blade.php",
                "public/css/*.css",
                "public/js/*.js",
            ],
            fn: function (event, file) {
                /** Custom event handler **/
            },
            options: {
                ignored: [
                    '*.txt',
                    '*.json'
                ]
            }
        },
        logPrefix:'L54',
    });

I dont' know if I am doing right, or maybe I have to set up Mix configuration or so. Any help would be much appreciated.

like image 930
llobet Avatar asked Mar 09 '23 04:03

llobet


1 Answers

Just for anyone still wondering, this seems to work on Laravel 5.5 (development branch):

mix.browserSync({
    proxy: 'https://www.site.example',
    files: [
        './resources/views/**/*.blade.php',
    ]
})
like image 87
Sebastiaan Luca Avatar answered Mar 26 '23 21:03

Sebastiaan Luca