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