Repository navigation
Open
Labels
Description
ISSUE TYPE
- Documentation
SUMMARY
As webpack-dev-server gets more popular and is also a big part of Symfony's webpack encore, I would kindly ask for a proper documentation of a correct setup.
Currently I need to add the following:
docker-compose.override.yml
version: '2.3'
################################################################################
# SERVICES
################################################################################
services:
# .....
# ------------------------------------------------------------
# PHP
# ------------------------------------------------------------
php:
ports:
- "8080:8080"
webpack.config.js
.configureDevServerOptions(options => {
options.client = {
host: '0.0.0.0'
};
options.firewall = false;
options.https = true;
})
and also the starting command needs to be: encore dev-server --https --host 0.0.0.0
package.json
...
"scripts": {
"dev-server": "encore dev-server --host 0.0.0.0 --https",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
...
Problems with this setup:
- SSL connection is always invalid. Adding the devilbox certificates to the
https: { ... }options object does not work hostneeds to be included in the yarn command to start the server, else it tries to use localhost- also
client.hostneeds to be specified somewhat redundantly to make the web socket working
Webpack Encore 1.0.4
Webpack 5.20.1
Webpack-dev-server: 4.0.0-beta.0
Devilbox 1.7.1
Also see: symfony/webpack-encore#828
Goal
Add a documentation guide for proper implementation of webpack-dev-server.
- working SSL connection
- probably with an per project
webpack-dev-server(wds)? (startingwdsin multiple projects simultaneously leads to problems
Would highly appreciate! Thank you for the great devilbox!
Activity
stale commentedon Jun 4, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
realspqrk commentedon Jun 4, 2021
Still having issues. I need to make an exception in Firefox everytime I switch projects, by right clicking a resource in the F12 developer tools and opening one in a new tab. I would really appreciate any help.
cytopia commentedon Jun 4, 2021
Hi @ptmrio you can find the reverse proxy setup within the documentation. It is pretty mich the same as this: https://devilbox.readthedocs.io/en/latest/examples/setup-reverse-proxy-nodejs.html
realspqrk commentedon Jun 10, 2021
Thank you @cytopia. I was pretty much on that path, but I couldn't get it to work. Could you help my with the logic behind this setup?
I'd guess, that I have to
0.0.0.0(or to the php container?)Thanks. And keep your great work up and running. IMHO this is the greatest project for web development there is. The modern WAMP of its time, but a thousand times better!
Edit: Just to be clear, it works partly for me with the following settings:
apache24.yml:
webpack.config.js
Added to
etc/hosts/127.0.0.1 webpack.locStartet with:
encore dev-server(Using Symfony webpack encore)
The only thing that does not work, is hot reloading.
GET wss://webpack.loc:4000/ws
I would guess, this is because the vhost doesn't listen to port 4000, only to 80 and 443. While config.output.publicPath changes the path for all files, the websocket path still tries port 4000, which is not listed to. Any suggestion?
science695 commentedon Jun 11, 2021
With Docker, you could map port 4000 to also go to 443, but you would need someway to identify traffic that is a websocket so that the upgrade header gets sent, and is forwarded to the webpack port instead of php-fpm. perhaps that /ws folder could be used in the virtualhost?
realspqrk commentedon Jun 14, 2021
Thanks @science695. I guess you'll have to make Docker + Apache/Nginx make listening to port 4000 and then edit the vhost accordingly for the reverse proxy. Unfortunately I'm not docker savvy enough to get it to work.
stale commentedon Sep 19, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
realspqrk commentedon Sep 20, 2021
Still not resolved for me. Can't get the websocket to work, it always runs on a different host or port. Still looking for help.
jose-sampedro commentedon Feb 13, 2022
@ptmrio any solution?
Could you share a repository with what you have investigated?
Thank you
realspqrk commentedon Feb 14, 2022
Nope, no "solution". Latest status is: #782 (comment)
I'm using
yarn watchinstead of any hot reload configuration atm. Part of the problem is the transition to webpack 5, part is this combination of browser, docker, and shared ports as well as my lack of knowledge. As mentioned a devilbox lamp + php + phpstorm + webpack (symfony encore) setup guide would be great as I think this is a rather popular setup.cytopia commentedon Dec 18, 2022
@ptmrio Currently working in automated reverse proxies for such use-cases. Should be available shortly
realspqrk commentedon Dec 19, 2022
@cytopia thanks lot, looking forward
cytopia commentedon Dec 26, 2022
@ptmrio
This is a websocket over SSL.
You can now set this easily via a
backend.cfgconfiguration in your project that hosts the websocket server.If the project providing the websocket server is
webpack.loc, then you would add the file in/shared/httpd/webpack/.devilbox/backend.cfg:# SSL Websocket Reverse Proxy backend conf:rproxy:wss:php:4000Then
watcherdhttps://webpack.locFor everything above to work, you will need to switch to the
v3.0.0-beta2release here: #943Side note
For troubleshooting I would first create a normal websocket server (without SSL) and tell the backend configuration to use
wsinstead ofwss:Once this is working, you can move on with SSL
realspqrk commentedon Dec 30, 2022
Thanks a lot, will try asap next year :)