Skip to content
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

devServer block in webpack.config.dev.js not being used after npm run eject #323

Closed
arnaugm opened this issue Aug 1, 2016 · 6 comments
Closed

Comments

@arnaugm
Copy link

arnaugm commented Aug 1, 2016

I executed the npm run eject command to have more control on the webpack configuration. I needed a proxy in the devServer.

start.js doesn't seem to use that configuration when creates the development server because proxy was not working. Executing webpack-dev-server --config config/webpack.config.dev.js, the proxy works properly.

Finally adding the proxy configuration in the script https://github.com/facebookincubator/create-react-app/blob/master/scripts/start.js#L154 solved the issue.

@gaearon
Copy link
Contributor

gaearon commented Aug 1, 2016

This sounds like the way webpack works—not something we could fix. (Yep, it can be confusing 😄 ) Would this new option solve your problem?

@alextreppass
Copy link

alextreppass commented Aug 2, 2016

webpack-dev-server run via the command line will auto-load config from a devServer block1.

Could the start.js script2 be tweaked to use `config.devServer, if found? Users could then edit webpack config to add things like proxy configuration in the standard way, without having to modify create-react-app scripts.


@gaearon
Copy link
Contributor

gaearon commented Aug 2, 2016

WepackDevServer CLI command does a whole ton of stuff to that config before feeding it to WebpackDevServer Node API. If we implement support for devServer, people will expect it to work the same way (with same defaults etc) but it won’t. So this is why we won’t implement it (and personally I don’t recommend CLI to anyone because of this option normalization that is so different from Node API). Sorry!

@gaearon gaearon closed this as completed Aug 2, 2016
@alextreppass
Copy link

alextreppass commented Aug 2, 2016

@gaearon thanks for the explanation, and I can understand our needs might not be a general case.

Would #282 let us proxy path patterns (e.g. /api*) to other hosts and avoid CORS out of the box? Or should we be standing up an external proxy for this?

Alternatively we can just eject and hand-edit scripts/start.js to add our webpack-dev-server proxy config there (it's a line of code to get at config.devServer and seems to proxy things ok), but then we might be causing future pain for ourselves if we want to upgrade to new versions of the tool.

On that note - have you guys had any thoughts on upgrading a created app? Do you see it as a helper that's just there at project setup time, or something projects can stick with and update to new releases?

@gaearon
Copy link
Contributor

gaearon commented Aug 2, 2016

Would #282 let us proxy path patterns (e.g. /api*) to other hosts and avoid CORS out of the box? Or should we be standing up an external proxy for this?

It lets you specify a single fallback server that would be used for any unrecognized path. If you have feedback on other use cases (e.g. you have multiple API servers?) please leave a comment in #282.

On that note - have you guys had any thoughts on upgrading a created app?

Changelog has detailed instructions on updating. Usually it’s a matter of bumping react-scripts dependency and running npm install.

@gaearon
Copy link
Contributor

gaearon commented Aug 2, 2016

Alternatively we can just eject and hand-edit scripts/start.js to add our webpack-dev-server proxy config there (it's a line of code to get at config.devServer)

As I said above this will not work as you expect from devServer option docs. It’s close but not exact, and I think it’s worse than just specifying options explicitly via Node API.

@lock lock bot locked and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants