Skip to content

Instantly share code, notes, and snippets.

@vades
Last active November 11, 2024 17:41
Show Gist options
  • Save vades/28f7e487192b3fbb61c429efd200cf1f to your computer and use it in GitHub Desktop.
Save vades/28f7e487192b3fbb61c429efd200cf1f to your computer and use it in GitHub Desktop.
Auto refresh after changes with Laravel Mix

Laravel auto refresh after changes

To achieve this you can use Laravel Mix

  1. Ensure that Node.js and NPM are installed: run node -v and npm -v.
  2. Install Laravel Mix npm install.
  3. Open webpack.mix.js and add mix.browserSync('127.0.0.1:8000');.
  4. Run php artisan serve.
  5. And the npm run watch.

Sources

@doglez
Copy link

doglez commented Mar 14, 2021

it work nice, thanks
npm install browser-sync
npm install browser-sync-webpack-plugin

@Sayyid01
Copy link

it's working flawlessly, Thanks!

if it not working for you, try to check if your node.js is installed or not.

@nikhilcb
Copy link

nikhilcb commented Aug 7, 2021

its stuck at [Browsersync] Reloading Browsers... . It downloaded so many files (500+) 100mb just for this, and still didnt work :)

@assetthawut
Copy link

Thanks, I confirm that it works.

use http://localhost:3000/ instead of http://localhost:8000/

image

@dogatonic
Copy link

Yes it is working. And just to help make it a little clearer...
You add mix.browserSync("127.0.0.1:8000"); to your webpack.mix.js
Then run php artisan serve
then also run npm run watch
then you set your browser tab to localhost:3000 and it will auto-refresh the browser every time you save a change in your code editor! Much like running GoLive.

HUGE time saver.

PS you can still tune in to localhost:8000 like normal, you just have to manually refresh the browser yourself.

@creoleuservinay
Copy link

Working Thanks

@jktnavy
Copy link

jktnavy commented Oct 31, 2022

It's work, thank you 👍

@KuchkoolShah
Copy link

it's work , thank you

Copy link

ghost commented Jun 20, 2024

Thanks a million

@ashirsaleh
Copy link

Works for me thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment