Skip to content

Instantly share code, notes, and snippets.

@vades
Last active November 11, 2024 17:41
Show Gist options
  • Select an option

  • Save vades/28f7e487192b3fbb61c429efd200cf1f to your computer and use it in GitHub Desktop.

Select an option

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

@hudacse6

hudacse6 commented Sep 8, 2020

Copy link
Copy Markdown

not working anymore, thanks

@ronnyandre

ronnyandre commented Nov 9, 2020

Copy link
Copy Markdown

Worked for me, thanks!

@doglez

doglez commented Mar 14, 2021

Copy link
Copy Markdown

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

@Sayyid01

Copy link
Copy Markdown

it's working flawlessly, Thanks!

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

@nikhilcb

nikhilcb commented Aug 7, 2021

Copy link
Copy Markdown

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

@assetthawut

Copy link
Copy Markdown

Thanks, I confirm that it works.

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

image

@dogatonic

Copy link
Copy Markdown

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
Copy Markdown

Working Thanks

@jktnavy

jktnavy commented Oct 31, 2022

Copy link
Copy Markdown

It's work, thank you 👍

@KuchkoolShah

Copy link
Copy Markdown

it's work , thank you

ghost commented Jun 20, 2024

Copy link
Copy Markdown

Thanks a million

@ashirsaleh

Copy link
Copy Markdown

Works for me thanks

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