When running node project, how to use the hot load of webpack

  node.js, question

Recently, a webpack has been used in the project. I feel that this feature of hot loading is very useful. however, since Node is used for rendering, when running the project, node is required to run. at this time, hot loading of webpack is not needed, because webpack and node monitor different ports.
The current practice is to use gulp to monitor static resources, execute webpack when there are changes, pack static resources into dist directory, and update static resource addresses referenced by html inside at the same time. However, it takes about 3 seconds for each package, and the browser needs to be refreshed manually, which feels that the development efficiency is very low.
I would like to ask you how to configure the webpack for server-side rendering projects.

Have you seen thiswebpack-dev-middleware?

If you useexpress, you can integrate this middleware into yournodeThe application of inside is very high.

Add:

The website has an example, as follows:

var webpackDevMiddleware = require("webpack-dev-middleware");
 var webpack = require("webpack");
 
 var compiler = webpack({
 // configuration
 output: { path: '/' }
 });
 
 app.use(webpackDevMiddleware(compiler, {
 // options
 }));

IfexpressPlay enough 6, the above code is clear and easy to understand