Skip to content

HMR with express server with NodeJS API #1511

Open
@Schachte

Description

@Schachte

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions