To install Browser Sync in Laravel run
npm i -D browser-sync
Webpack Tweak
in webpack.mix.js add
mix.browserSync('laravel.test');
NPM Watch
Then run:
npm run watch
to start watching for changes. And see the Laravel app opening in http://localhost:3000/ and reloading on changes:
Browsersync] Proxying: http://laravel.test [Browsersync] Access URLs: -------------------------------------- Local: http://localhost:3000 External: http://192.168.1.100:3000 -------------------------------------- UI: http://localhost:3001 UI External: http://192.168.1.100:3001 -------------------------------------- [Browsersync] Watching files...
Watching PHP Changes
To sync PHP Changes you can use
browserSync({ files: [ 'app/**/*', 'public/**/*', 'resources/views/**/*', 'routes/**/*' ] }); mix.browserSync('laravel.test');
with the addition of specific files to be synched.