enten / udk

Universal Development Kit: Webpack extension which improves universal application development. - THE UDK PROJECT SUPPORT IS CURRENTLY SUSPENDED.
MIT License
29 stars 7 forks source link

How do integrate HMR on client side? #13

Closed beckend closed 5 years ago

beckend commented 5 years ago

I do not see that it's starting a server of any kind, how would the setup look like to enable HMR on browser client?

beckend commented 5 years ago

I am using the dev container by the way. And Koa

enten commented 5 years ago

If a node bundle exports an http server instance, the container tries to decorate the request listener: it uses webpack-hot-middleware if option hmr is enabled (source).

In other words, when a main entry point of a webpack config with target "node" exports an http server instance: the dev container try to mount webpack-hot-middleware on path /__webpack_hmr.

Try to export an http server instance on your node entry point and check path /__webpack_hmr on your server to see if it returns something else than an 404 code.

This path is provided by webpack-hot-middleware as a server sent events and use it to allow HMR on client.

beckend commented 5 years ago

I see, i got it working, thanks