Skip to content

Configuration for webpack dev-server in vm/docker for rebound host interfaces #9343

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

Closed
wants to merge 1 commit into from

Conversation

pscheit
Copy link

@pscheit pscheit commented Feb 26, 2018

This is the discussion, for setting an absolute url as publicPath, when you're binding the dev server not to localhost but to any external interface (0.0.0.0) and disable host checking:

symfony/webpack-encore#96

The problem is, that when you bind the dev-server to all interfaces with --host 0.0.0.0 this url will be written to the manifest.json, when versioning is used:
`"build/main.js": "http://0.0.0.0:8080/build/main.js",

Instead the external-interface should be used:
`"build/main.js": "http://192.168.1.1:8080/build/main.js"

When in docker, you need a port mapping, to make the dev-server accessible, when browsing the site with a browser running on the host.
(please note, that it isn't possible to access docker containers with their internal ip from the host, when running docker on windows. That's why we should always recommend a host-port-mapping for the docker-container)

best regards
philipp

@pscheit pscheit changed the title Configuration for dev-server in vm/docker for rebound host interfaces Configuration for webpack dev-server in vm/docker for rebound host interfaces Feb 26, 2018
@javiereguiluz javiereguiluz added the help wanted Issues and PRs which are looking for volunteers to complete them. label Mar 5, 2018
@xabbuh xabbuh added this to the 3.4 milestone Apr 20, 2018
@xabbuh xabbuh requested a review from weaverryan April 20, 2018 10:22
@javiereguiluz
Copy link
Member

@Lyrkan could you please review if the proposed changes here are correct according to the latest Encore versions? Thanks.

Copy link
Contributor

@Lyrkan Lyrkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... even though it probably still works I think it would be better to use the --public option that was recently fixed by @lyrixx in symfony/webpack-encore#529.

Main reasons:

  • You don't have to add an additional check to your webpack.config.js file (and if you do it'd be better to use if (Encore.isDevServer()))
  • It keeps all the "dev-server"-related options in the command line (with --host and --disable-host-check)
  • You won't get the warning that is triggered by calling setPublicPath with an absolute URL

@pscheit
Copy link
Author

pscheit commented Mar 20, 2019

sorry guys, I did read your comment, but my brain did not convert that into an actual action :)

I replaced the config option with using --public. I tested this right now and works, too. It's much cleaner like this.

@javiereguiluz
Copy link
Member

@Kocal could you please review this proposed change? (Don't worry about grammar issues or syntax issues because we can fix those while merging). Thanks!

@Kocal
Copy link
Member

Kocal commented Sep 23, 2019

There is already https://symfony.com/doc/current/frontend/encore/virtual-machine.html that covers webpack dev-server usage inside a VM, so I don't think we need those modifications. :/

Or maybe add a link to it... I don't know.

@javiereguiluz
Copy link
Member

Thanks for this contribution, but as @Kocal said, this is probably covered in other articles already. Let's close for now, but we can reconsider this decision in the future when we receive more feedback from the community. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end help wanted Issues and PRs which are looking for volunteers to complete them. Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants