trogne's avatar

hot module reloading without having to change links

When I use hot module reloading with laravel, like with npm run hmr, I have to change my script links, like replacing <script src="/js/app.js"></script> with <script src="http://localhost:8080/js/app.js"></script>.

Is there a way I can automatically serve some files from "localhost:8080" when running npm run hmr ?

0 likes
3 replies
trogne's avatar

Can I do something like this :

if (Mix.isUsing('hmr')) {
   someconfigforserverroot = 'http://localhost:8080' 
}
trogne's avatar

I also wonder why "hmr" needs to be on a separate server

trogne's avatar

My answer is here :

...\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php

The "mix" function.

return new HtmlString("//localhost:8080{$path}");

Please or to participate in this conversation.