Make it possible to share HTTP server (eg with koa) #114
Description
Thanks for this awesome module! I was able to get it working by configuring a static websockets port and creating another port-forward in my docker-compose. This feature request is to make it possible for koa-webpack to configure webpack-hot-client to attach its websockets to koa's existing http server. so that an additional port is not needed.
- Operating System / node / npm version: docker node:latest
- webpack Version: 4.43.0
- webpack-hot-client Version: 4.1.2
Your readme says: "If a server instance (eg. Express or Koa) is provided, the WebSocket server will attempt to attach to the server instance instead of using a separate port."
Please document how to do this. I tried the obvious things like passing in the http server and passing in the koa instance.
I also spent some time looking at your source code... it doesn't look like this feature exists.
I would very much like the websockets to use the http.createServer() that koa uses, so I don't have to configure it to use a static port and forward another port out of docker.
If I pass in an http.createServer() object then your module calls .listen() on it:
webpack-hot-client/lib/socket-server.js
Line 12 in 1b7f221
which makes it so koa can't call .listen() on it. So this doesn't achieve sharing between webpack-hot-client and koa.
I was going to put a feature request into koa-webpack, but I don't think that webpack-hot-client makes it possible, so I'm writing here.
Thanks!