symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 198 forks source link

Access dev-server from inside and outside docker #1202

Open packagespace opened 1 year ago

packagespace commented 1 year ago

Hello,

Apologies if this has been asked before or if I'm missing something really obvious.

I'm currently locally running a Dockerized Symfony app, with a node container running the dev-server command. Now, while this runs great when developing, I've been running into an issue when trying to implement E2E tests using Panther, where the test browser (running in the php container) cannot access assets.

My understanding of the issue is that the entrypoints.json file points to the correct URL when developing (localhost:8080) but since the test browser is running in the php container, the correct URL would be node:8080 or host.docker.internal:8080.

I've tried to change this manually in entrypoints.json as a test, and it does work, but my real browser can in turn no longer access the dev-server assets.

My question is now: How do I achieve this without having to launch a command before running my tests again? I'm aware I could use watch mode instead, but I'd like to keep the benefits of using dev-server and be able to run my tests from my IDE without having to worry about what command my node container is currently running. I suppose I could also build my assets before running tests, but this slows down the process a considerable amount.

My node container command:

    command: 'sh -c "npm install; npm run dev-server -- --live-reload --server-type https --client-web-socket-url https://localhost:8080/ws --host 0.0.0.0 --public https://localhost:8080 --allowed-hosts all"'

Options I've thought of so far:

Would greatly appreciate any help or ideas on this.

Cheers.

carsonbot commented 1 week ago

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?