Search code examples
parceljs

How to stop local server with Parcel bundler


I am using API of Parcel bundler to build and start a local server.

const Bundler = require('parcel-bundler');

let entryFile = ...;
let options = ...;

(async function() {
    let bundler = new Bundler(entryFile, options);
    let b = await bundler.serve();
)();

I would like to stop the server at some point. I cannot find this in their documentation. Is there a method that allows me to stop the server?


Solution

  • Yes, there is a method close.

        let bundler = new Bundler(entryFile, options);
        let b = await bundler.serve();
    
        b.close();