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

Dev server detection workaround #2890

Closed
wants to merge 4 commits into from
Closed

Dev server detection workaround #2890

wants to merge 4 commits into from

Conversation

crawler
Copy link
Contributor

@crawler crawler commented Jan 15, 2021

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.

without relying on webpack-cli or webpack-dev-server packages
@pedrofurtado
Copy link
Member

@crawler A doubt: is this PR related to this issue #2832 ? Or not? 🤝

@crawler
Copy link
Contributor Author

crawler commented Jan 15, 2021

@pedrofurtado
Partially, both issues are caused by migration to the newer webpack-dev-server / webpack cli. My pull request does not solve the live reload issue, it only ensures that our dev server configuration is not skipped when you run bin/webpack-dev-server command. Exactly in my case, even port was 8080

@pedrofurtado
Copy link
Member

@crawler Thanks for clarification! Anyway, thanks for your contribution in this PR!🤝 👍

@pedrofurtado
Copy link
Member

@gauravtiwari Your eyes/reviews on it will be awesome 🎉

@gauravtiwari
Copy link
Member

gauravtiwari commented Jan 19, 2021

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

@gauravtiwari
Copy link
Member

gauravtiwari commented Jan 19, 2021

@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.

@crawler
Copy link
Contributor Author

crawler commented Jan 19, 2021

Hi @gauravtiwari, thank you for looking into this. Sorry for messing up with this PR. I created a new one #2898

@crawler crawler closed this Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants