Laravel 5.4 clock files with browser sync

In laravel 5.4 mix and browserSync come by default. I want my browser to be updated with new changes if I change any *.blade.php

files from resources/views

. In mine webpack.mix.js

, I have 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 don't know if I am doing the right thing, or maybe I need to tweak the Mix config or so. Any help would be much appreciated.

+3


source to share


2 answers


But do assets /public

reload normally?

Anyway, I think you don't need to specify the files to view as they are standard. My config is just

mix.browserSync({
  proxy: 'theapp.dev'
});

      



However, if you need to change this part of the config (for a custom callback), the parameter files

must be an array (which accepts both strings and objects):

browserSync({
  files: [                           // 'files' array
    "wp-content/themes/**/*.css",      // 1st element
    {                                  // 2nd element
      match: ["wp-content/themes/**/*.php"],
      fn:    function (event, file) {
            /** Custom event handler **/
      }
    }                                  // end 2nd element
  ]                                  // end 'files' array
});

      

+2


source


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



mix.browserSync({
    proxy: 'https://www.site.example',
    files: [
        './resources/views/**/*.blade.php',
    ]
})

      

+1


source







All Articles