-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable custom sockjs pathname for hot reloading server. #7750
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, it looks good. Only a few minor suggestions from me!
Perhaps we should add support for configuring the other values (port, hostname) here as well? That way if you serve the app over a different hostname (e.g. |
@heygrady I like @rovansteen's suggestion. Do you think you could get that in here? Something happened to the CI, sorry about that. I know it's working better today, but still needs love. |
This looks good to me if we can get the build green. Are the issues with the CI resolved now? |
rebased and force pushed |
Oh, needs to have more recent version of webpack-dev-server. |
The other options ( I went ahead and upgraded to version 3.9.0. |
The kitchen sink tests are failing because of a cryptic error, |
dc401b3
to
eb7bef9
Compare
@mrmckeb I'm curious about next steps. I don't suspect that the CI kitchensink failures are directly related to this PR. I run a fork where I've had the upgraded webpack-dev-server for quite a while and I don't have any issues. |
Would be wonderful to have this merged. We are running multiple projects simultaneously and this PR would make life much easier. |
@matejstrasek I put together a gitpkg of this PR at https://github.com/twschiller/create-react-app/tree/react-scripts-v3.2.0-gitpkg. Add it to your packages.json like so:
|
8f7e13d
to
6f20cfd
Compare
Rebased. All tests should be passing now. |
Was wondering if this is still going to be pushed through now that it has been approved? Looks like the milestone has passed |
Co-Authored-By: Brody McKee <mrmckeb@users.noreply.github.com>
Would love to see this merged. We ran into this while we were migrating our legacy codebase incrementally over to React and we're including the React bundle in our main application while running two distinct dev servers. In this scenario, we need to override the defaults to get HMR to work. @heygrady any idea why builds are failing? I'm unable to see the logs on Azure Pipelines. |
Thanks for your patience everyone! Please note that env var configuration might be changed to config file in the future. |
Fixes #7597
See also https://github.com/dmile/create-react-app/commit/d86b05e9d327b368f664f6b9846ecac9806bca70 and #7444 (comment)
Enables setting the
sockPath
option for the webpack-dev-server using a newWDS_SOCKET_PATH
environment variable. This env controls the websocket connection pathname used by the hot reloading client/server.Primary use-case would be starting a development server for multiple projects simultaneously. It's already possible to specify a
PORT
for the development server. When proxying multiple projects behind a single domain it is also necessary to customize thesockPath
.Why?
There are many valid reasons to develop locally with a custom hostname. It is also common in real-life productions apps to proxy to different apps based on pathname.
Imagine that we are running a local nginx proxy at
local.example.com
like so:http://local.example.com/project-a
-> localhost:3001http://local.example.com/project-b
-> localhost:3002# start two projects with different ports and different sock paths $ PORT=3001 WDS_SOCKET_PATH=/sockjs-node/project-a yarn start $ PORT=3002 WDS_SOCKET_PATH=/sockjs-node/project-b yarn start
Of course we also need to proxy the sockjs pathnames with nginx as well.
This rig enables an app to be developed similarly to how it will appear in production.