How does webpack-dev-middleware work with the express rendering engine?

after using webpack-dev-middleware , the generated html is in memory,
but the route of express, for example,

//app.js
app.set("views", path.join(__dirname, "views"))

// routes.js
router.get("/home", (req,res) => {
  res.render("home")
})
The

rendering engine is looking for home.html in the views folder, but returns 500because home.html is in memory and express cannot find it.

how does webpack-dev-middleware cooperate with express rendering engine?

Mar.01,2021

replace 'home' with your html string


write to the views folder when developing using the webpack-dev-middleware property writeTodisk, which is fine.
however, it doesn't feel like the optimal solution, so you should modify the in-memory data generated by res.render to read webpack-dev-middleware.

Update: the above method produces a pile of temporary files and is discarded.

< hr >

do not use the webpack-dev-middleware attribute writeTodisk
use html-webpack-harddisk-plugin to only export html, to improve the shortcomings of the above scheme.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36329-2bfff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36329-2bfff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?