trogne's avatar

mix and hmr

How do I use the "npm run hmr" script ?

When I run it I get this :

i 「wds」: Project is running at http://localhost:8080/
i 「wds」: webpack output is served from http://localhost:8080/
i 「wds」: Content not from webpack is served from D:\htdocs\laracasts\learn-vue-2-step-by-step\oofp\public
i 「wds」: 404s will fallback to /index.html

But going there I get "Cannot GET".

I'm on Windows 10, running my laravel project on homestead.

I access my laravel project at "oofp.local", which points to 192.168.10.10

0 likes
6 replies
trogne's avatar

When I save a file under "resources/js", I see "Compiled successfully", but it does not change the files under "public" dir. "webpack" does that, but not "webpack-dev-server".

How can I use "npm run hmr" so that it compiles to the same place as using normal "webpack" ?

Can I use hmr and still visitng my laravel project on "mywebsite.local" (pointing to homestead 192.168.10.10) ?

trogne's avatar

Also, after running "npm run hmr", visinting "localhost:8080/index.php" in browser will ask me to download that index.php file.

trogne's avatar

"npm run hmr" is just serving the "public" directory. The Laravel app is not even accessible.

trogne's avatar

Oh I understand !!!

First I needed the "Mix.listen" section at the end of github thread mentioned above.

Running "npm run hmr" starts a server hosting the public directory.

So I have to visist my laravel homestead app as normal.

And in my blade file, I have to change the script href to point to the "hmr" server, in my case localhost:8080/js/app.js .

I know there's maybe a "mix" function that could figure out that link, with src="{{ mix('/js/app.js' ) }} do that, but I'm on laravel 5.3 and it seems this "mix" function is non-existent.

trogne's avatar

So I have one question :

How can I let laravel know that I'm using HMR, so that I can automatically serve my assets from "localhost:8080" instead of from the same server ?

Please or to participate in this conversation.