Macil / browserify-hmr

Hot Module Replacement plugin for Browserify
MIT License
374 stars 26 forks source link

Can't get it to work from remote server #37

Closed akralj closed 7 years ago

akralj commented 7 years ago

hi, i'm using: watchify -vd -p browserify-hmr -e src/main.js -o dist/js/build.js which works fine from localhost, but i cant get hmr to work when i develop from a remote server. I tried things like: watchify -vd -p [browserify-hmr -h remoteServer -u http://remoteServer:3123] -e src/main.js -o dist/js/build.js but no luck. I create a ssh tunnel with ssh -NL 3123:localhost:3123 user@serverName as a workaround, but that's less then ideal.

Any advice would be greatly appreciated thanks andrej

Macil commented 7 years ago

-h 0.0.0.0 should do the trick to listen on all interfaces. I think I might need to add that to the readme.

akralj commented 7 years ago

Thank you so much for this. Saved me from switching to webpack.... Could you please add add a complete example to the docs, e.g.

If you want to use HMR from a remote development server use a config similar like the next line:

watchify -vd -p [browserify-hmr -h 0.0.0.0 -u http://remoteServer:3123] -e src/main.js -o dist/js/build.js

Wouldn't it be possible to get rid of the -u switch by just using location.origin on the client? Or thinking it even further. what would be the harm of just having -h 0.0.0.0 + location.origin as the default. just my 2cts thanks again :)