hackingbeauty / jimjam-boilerplate

Foundational UI Boilerplate For React Apps
http://jimjamboilerplate.com
40 stars 10 forks source link

Cannot build application websockets on top of this #3

Open builtbybrayne opened 6 years ago

builtbybrayne commented 6 years ago

Hey,

So, it turns out that it's not trivial to add one's own websockets to an application using webpack hot module replacement (https://www.reddit.com/r/javascript/comments/6jbg2f/one_does_not_simply_use_websockets_with_webpack/).

Now, I believe it can be done (as per the comments in the link), but I know nothing about webpack internals, so it's hard for me to compare the configuration in those comments and this boilerplate.

Could you please have a look at the links above and see whether this boilerplate could be modified just enough to allow websockets to work? Or if you have suggestions/workarounds that would also be fine.

Cheers

builtbybrayne commented 6 years ago

Actually, I managed it with just the following additional config in webpack/dev.config.js:

devServer: {
    proxy: {
      '/ws': {
        target: `http://localhost:${wsPort}/ws`,
        secure: false
      }
    }
  }

I got wsPort from my env variables.

Maybe this is helpful to someone else too. But for me, this issue can be closed.

(Although I think putting 'websocket compatible' in your list of features would probably be No Bad Thing).

Edit: Also needless to say, this involves running your websockets on a different port in your server.