programmatically or CLI to stop webpack-dev-server
Asked Answered
R

1

6

How to stop webpack-dev-server programatically of a CLI command against the port ?

Ctrl-C etc are good for manually stopping the server. We are basically killing it.

Is there a API that the server exposes to issue a STOP command or something ?

Rexanna answered 2/8, 2018 at 17:28 Comment(0)
D
2

Just came across this. Hopefully it's still relevant^^

According to documentation, the server can be opened and closed via node api as follows:

// create instance
const server = new WebpackDevServer(webpack(config), { });

// start
server.listen(8000, "localhost", err => {
    console.log("server started")
})

// close/stop
server.close(() => {
    console.log("server closed")
})

Docs: https://github.com/webpack/docs/wiki/webpack-dev-server

Descry answered 16/5, 2019 at 12:53 Comment(1)
Angular CLI does not seem to expose something like this. I think what is needed in CLI is some http call to hit the dev server that should stop the server.Rexanna

© 2022 - 2024 — McMap. All rights reserved.