Home / Snippets / How to Set Up BrowserSync Live Reloading in Laravel 8
How to Set Up BrowserSync Live Reloading in Laravel 8 cover

How to Set Up BrowserSync Live Reloading in Laravel 8

1.1K

3 years ago

0 comments

For a seamless front-end development in Laravel, you can make use of BrowserSync. BrowserSync can automatically monitor your files for changes, and inject your changes into the browser without requiring a manual refresh. You may enable support for this by calling the mix.browserSync() method.

1 - Install BrowserSync
Add BrowserSync using npm or yarn.
yarn add browser-sync browser-sync-webpack-plugin@^2.3.0 --dev

2 - Add BrowserSync in Laravel Mix
Define the configuration for BrowserSync and pass in the proxy URL of the project.
# webpack.mix.js

mix
    .js('resources/js/app.js', 'public/js')
    .browserSync({
        proxy: 'https://laravel-app.test'
    });

3 - Watch Assets for Changes
Now you can "run watch" command to monitor the assets for changes.
yarn watch

# or 
npm run watch
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this