Parcel dev server but with support for proxies
npm install parcel-proxy-serverA small wrapper around the parcel development server
that adds support for proxies, just like webpack.
``bash`
yarn add parcel parcel-proxy-server
or
`bash`
npm install parcel parcel-proxy-server
This project exposes an api for starting up a proxy server.
Example:
`js
const ParcelProxyServer = require('parcel-proxy-server');
// configure the proxy server
const server = new ParcelProxyServer({
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://parceljs.org/api
https: true
},
proxies: {
// add proxies here
'/api': {
target: 'https://example.com/api'
}
}
});
// the underlying parcel bundler is exposed on the server
// and can be used if needed
server.bundler.on('buildEnd', () => {
console.log('Build completed!');
});
// start up the server
server.listen(8080, () => {
console.log('Parcel proxy server has started');
});
`
This wrapper doesn't do too much under the hood.
A parcel bundler is created using the configuration that is passed in.express
An 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 true,HMR` can still function.
the server will generate certs and provide that
to the server that gets created so that things like