-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dev server detection workaround #2890
Conversation
without relying on webpack-cli or webpack-dev-server packages
@pedrofurtado |
@crawler Thanks for clarification! Anyway, thanks for your contribution in this PR!🤝 👍 |
@gauravtiwari Your eyes/reviews on it will be awesome 🎉 |
Thanks both, I looked into it last week and this issue is related to: webpack/webpack-cli#1973 but wasn't sure about the exact solution to the problem since webpack dev server 4 is still unreleased. Also, this PR adds a new env variable: webpack/webpack-cli#2027 I need to dig deeper to understand what's going on and how this is changed in 4.0 |
@crawler Yes, that makes sense and I was thinking along the same lines to add our own env variable inside webpack dev server binstub. Although, not sure about the inject client so if you could remove that bit and move to another pr then we can merge this straightaway. |
Hi @gauravtiwari, thank you for looking into this. Sorry for messing up with this PR. I created a new one #2898 |
Not sure how it works for everyone else. But as I can see, the webpack-cli@4.2.0 requires the webpack-dev-server package after our development.js file is loaded, so process.env.WEBPACK_DEV_SERVER variable is not yet available. This resulting devServer config section skipped when bin/webpack-dev-server is executed without manually setting env variables.
Looks like this problem is solved in webpack-cli@4.3.0 with a WEBPACK_SERVE environment variable (webpack/webpack-cli/pull/2027). But because the master branch is linked to 4.2.0 I came up with this solution. And I think that this is maybe a good idea to not rely on the environment variable that is set somewhere in the internals of the other project when it can be coupled within one repo.