webpack icon indicating copy to clipboard operation
webpack copied to clipboard

HMR with express server with NodeJS API

Open Schachte opened this issue 4 years ago • 0 comments

My goal here is to get a bundle for my serverside express bundle with HMR support using the webpack NodeJS API. I'm not quite sure if I'm approaching this problem correctly.

  // returns 2 item array [0] = client [1] = server
  const config = webpackConfig();

  const devServer = { host, port, ...config.devServer }

  WebpackDevServer.addDevServerEntrypoints(config[0], devServer)

  const compiler = webpack(config)
  const server = new WebpackDevServer(compiler, devServer)

  server.listen(port, host, err => {
    if (err) {
      console.error(err)
      process.exit(1)
    } else if (args.open) {
      openBrowser(`http://${host}:${port}${publicPath}/`)
    }
  })

I'm hoping that the server for node (express) will be running as well as the clientside bundle. How can I achieve this?

Schachte avatar Oct 31 '19 18:10 Schachte