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.
source to share
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
});
source to share