Parcel: Is there a way to get HMR working when running within another local server

Created on 3 Mar 2020  ·  8Comments  ·  Source: parcel-bundler/parcel

❔ Question

Is there something similar to https://github.com/webpack-contrib/webpack-hot-middleware for Parcel?

🔦 Context

I'm building a WordPress plugin on _my.local_ and Parcel is running at _localhost:1234_, but I want HMR working at my.local

Waiting Question HMR

All 8 comments

Not sure if this is really useful in your situation but have you seen https://parceljs.org/api.html#middleware ?

Thanks for the quick reply.

I researched this a bit and found https://torquemag.io/2019/02/using-express-to-build-a-node-js-server-to-proxy-the-wordpress-rest-api/ but that's just to get to the REST API from the WordPress site, which isn't what I'm needing.

So I think not, but I'm not an expert in these things.

What you can do is use pass --hmr-host localhost to parcel, so that the HMR runtime in the browser doesn't use the current url (my.local) but localhost instead

Awesome! https://parceljs.org/cli.html

_(FYI: it's --hmr-hostname ...)_

That worked when at http://my.local but not https://my.local, even with --https in Parcel's command (I also tried adding --hmr-port 3030 but no dice) with this appearing in Chrome's Console:

WebSocket connection to 'wss://localhost:62249/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

Any ideas about that?

ERR_CERT_AUTHORITY_INVALID
Any ideas about that?

See https://github.com/parcel-bundler/parcel/issues/2805

So awesome! tyvm for your quick help. Really unblocked me :D

Here's a short demo of it working on _https_, for anyone's reference: https://share.getcloudapp.com/o0uDmLZr

And, for Parcel authors, I wonder if there's some voodoo here to make the "allowing" part no longer necessary: https://serverfault.com/questions/845766/generating-a-self-signed-cert-with-openssl-that-works-in-chrome-58

I wonder if there's some voodoo here to make the "allowing" part no longer necessary

Happy to accept improvements, but I don't know either 🤷‍♂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliger picture oliger  ·  3Comments

termhn picture termhn  ·  3Comments

466023746 picture 466023746  ·  3Comments

dotdash picture dotdash  ·  3Comments

algebraic-brain picture algebraic-brain  ·  3Comments