webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.
MIT License
7.79k stars 1.43k forks source link

Sockjs live reloading migration from v3 to v4 unclear #4382

Closed WisaniShilumani closed 7 months ago

WisaniShilumani commented 2 years ago

Documentation Is:

Please Explain in Detail...

Webpack-dev-server config options migration from v3 to v4 is not clear with regards to changes to websocket options; particularly when using sockjs protocol, given the new defaulting to the ws protocol.

When the sockjs protocol is provided in options, the SockJS server is bound to the '/ws' path.

This is fixed by adding the webSocketServer options as such:

webSocketServer: {
  type: 'sockjs',
  options: {
    path: '/sockjs-node'
  }
}

Your Proposal for Changes

This should be communicated in docs, or the defaultWebSocketServerOptions in lib/Server.js [line 1517] currently: const defaultWebSocketServerOptions = { path: '/ws' }

should have the path be equal to client.webSocketURL or client.webSocketURL.pathname

alexander-akait commented 2 years ago

Socksjs supports ws and versa vice too, it was replaced in runtime based on supporting

WisaniShilumani commented 2 years ago

Thanks @alexander-akait, does this need to be documented here https://webpack.js.org/configuration/dev-server/#websocketurl so that the developer knows that the path needs to either be '/ws', or they must set it under webSocketServer.options.path?

alexander-akait commented 2 years ago

Based on your configuration, if you have before non default options, you need to update, but if you don't change it, you can don't touch it and all will work

WisaniShilumani commented 2 years ago

Alright, if it doesn't warrant a docs update, happy if we close the issue!

alexander-akait commented 2 years ago

@WisaniShilumani We can improve docs, so feel free to send a PR, any docs updates are good for developers

WisaniShilumani commented 2 years ago

Thanks @alexander-akait I will open a PR shortly!

alexander-akait commented 7 months ago

Closing due to inactivity. Anyway feel free to send a PR. Thanks!