Search code examples
parceljslando

Lando wtih ParcelJS: exposing port


I'm trying to use ParcelJS with Lando and there's one problem if you want HMR to work. You need to expose a port and that seems to be much harder than it should be with Lando. :(

So I know I need to do this for my ParcelJS watch command:

parcel watch dev/scripts.js --out-dir prod/ --hmr-port 6101

Then I need to expose the port I've assigned, in this case "6101" to Docker (via my Lando config file). But that's where it's tricky, apparently, because of the proxy setup Lando uses.

My current .lando.yml config is below, but it doesn't work as expected and the port is not exposed. I still get a "scripts.js:224 WebSocket connection to 'wss://testwp.lndo.site:6101/' failed:" error message from my ParcelJS generated script file in my browser's dev tools:

name: testwp
recipe: wordpress
config:
  php: '8.0'
  via: nginx
  webroot: wordpress
  database: mysql:8.0
services:
  appserver:
    portforward: 6101

Solution

  • I saw a similar post about a problem with LocalWP which does about the same thing Lando does.

    Can you maybe try to add the flag --hmr-hostname localhost.

    Its ether that or --hmr-hostname testwp.lndo.site.

    UPDATE:

    After checking the parcel CLI docs the flag could also be --hmr-host localhost try that aswell.