-
-
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
Specify custom WebpackDevServer url for webpackHotDevClient #1936
Comments
Does the advanced configuration section help you? Specifically Did you try visiting the dev server endpoint instead and using the proxy option? If one of these don't fulfil your use case, please explain what you are trying to do in more detail (and explain why these existing solutions are not sufficient for you). |
Hey!
So this probably rules out The proxy option would have worked if it wasn't for the initial data required to make any api requests. Further it feels kindof awkward and reversed that the dev-server proxies requests to the backend and not the opposite, or maybe that's just me? So I see two options for my case,
|
Is all of this information stored in the cookie? You could use Optimally, you'd opt for option 1.
A zero-configuration solution is always preferred to a configuration ridden one. As for "specifying" where the dev server actually is, I'm not sure we want to expose this bit of configuration.
Why so? A development server should always proxy off to what it needs IMO. I will /cc @gaearon to see if he has time to provide his opinion on this. |
Well it wouldn't be much configuration, only to tell the hotDevClient where the devServer lives. Using proxy has multiple disadvantages for me. It feels like it was created as a way to have the api on the same origin as the web page. Which is not my case. It would be a great advantage for me to serve the webpage from my own backend. That way I can have preloaded state and meta tags pre rendered... Using proxy, I'd lose all this functionality only because hotDevClient expects devServer to live at the same origin. An option could be to have the devServer proxy off calls to anything that isn't the js or css bundle or /socksjs-node. That way I could have the initial document created by my backend as I want. Thank you! |
I have a poc in my own private project! I will create one as soon as I have some time over! Basically I do two things:
Setting <script data-public-path="http://localhost:3000/" src="http://localhost:3000/static/js/bundle.js"></script> and in entry if(document.currentScript.dataset.publicPath) {
__webpack_public_path__ = document.currentScript.dataset.publicPath
} and in webpackHotDevClient.js i am assuming that devServer url and publicPath are the same maybe devServer url should be explicit though.. devServerWSS = __webpack_require__.p + '/socksjs-node' |
Can you take a look at #1994 and see if it would solve your problem - I am doing a similar thing and the change in that PR fixed it for me |
@dburrows @Timer #1994 indeed implements the key part of the feature I am proposing. However, webpack-dev-server configuration states that.
See https://webpack.github.io/docs/webpack-dev-server.html#additional-configuration-options |
Aha, ok, I haven't tried chunk loading, will have a look - would definitely be nice to fix it fully. |
I'll close this as stale. We can take PRs that make internals more reusable as long as they don't complicate the ejected code. Other than that it's a bit hard for me to discuss without a very specific proposal in form of a PR. |
Would you be interested in having the possibility of setting a different url for WebpackDevServer than the current
window.location
? see https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/webpackHotDevClient.js#L129In my project I have a different server that serves the react-app bundle. Because of this, I am not able to use webpackHotDevClient with its current configuration. This is because the webpackHotDevClient assumes the app runs from the same location as the WebpackDevServer.
webpack-dev-server/client allows for this by using the magical constant
__resourceQuery
https://github.com/webpack/webpack-dev-server/blob/master/client/index.js#L22If you're interested I'd be happy to open a pr for with.
Thank you
The text was updated successfully, but these errors were encountered: