0

We are trying to set up GULP file to serve PUG files into HTML and put them into static dist folder.

Here are our files: https://github.com/ShooX512/gulp-testing/

This is how we control PUG so far:

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

but because of the fact that GULP generates HTML files in dist we have added this:

app.use(
  "./dist",
  express.static(path.join(__dirname, "./dist"), { maxAge: "30 days" })
);

This unfortunately doesn't work.

My main questions are:

Which version of the code should be used and when?

How to pass data to generated HTML files in dist folder? (Originally PUG)

Do we need GULP to compile PUG at all if we use:

app.set("view engine", "pug");
app.set("views", path.join(__dirname, "./dist/"));
Graham
  • 7,431
  • 18
  • 59
  • 84
ShooX
  • 1
  • Use the bottom one. It will likely be faster, and it removes confusion on your end – pmkro Mar 27 '19 at 21:36
  • Following template engines are supported by express.js https://expressjs.com/en/resources/template-engines.html It is better to use them directly rather than using gulp to pre-process. – dRoyson Mar 28 '19 at 08:27

0 Answers0