About the problems encountered in returning templates in express+webpack

novice rookies started to use express + webpack to build, and encountered the following problem: the front end packages the files through webpack-dev-middleware and stores them under the output/ directory. If you want to return the template through express, I want to set it this way

app.set("view engine", "hbs");
app.set("view", path.resolve(__dirname, "../output"));

...
res.render("index", {
    title: "hello world",
})

found that if you set it in this way, the folder does not exist. Refer to other people"s writing and change it to the following:

 app.get("*", function (req, res) {
        res.write(middleware.fileSystem.readFileSync(path.join(__dirname, "../output/index.html")));
        res.end();
 });

what is the difference between the two writing methods, and why not? Thank you

Mar.07,2022

template engine is not used correctly, app.set ('view engine',' html'); . For more information, please see express official documentation app.engine ;)


clipboard.png
:

clipboard.png

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-7b0e4f-29417.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-7b0e4f-29417.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?