A small wrapper around the parcel development server
that adds support for proxies, just like
yarn add parcel parcel-proxy-server
npm install parcel parcel-proxy-server
This project exposes an api for starting up a proxy server.
const ParcelProxyServer = ;// configure the proxy serverconst server =entryPoint: './path/to/my/entry/point'parcelOptions:// provide parcel options here// these are directly passed into the// parcel bundler//// More info on supported options are documented at//https: trueproxies:// add proxies here'/api':target: '';// the underlying parcel bundler is exposed on the server// and can be used if neededserverbundler;// start up the serverserver;
How it works
This wrapper doesn't do too much under the hood.
parcel bundler is created using the configuration that is passed in.
express server is started and
http-proxy-middleware is used
to apply proxies. The bundler middleware then applied to the express
server to serve files.
To preserve some of the behaviour that the vanilla
parcel serve command supports, the project.
For example, if the
https option is set to
the server will generate certs and provide that
to the server that gets created so that things like
HMR can still function.