mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
https://mozilla.github.io/nunjucks/
BSD 2-Clause "Simplified" License
8.48k stars 635 forks source link

Templates won't change unless server is restarted? #1394

Open phantom2152 opened 2 years ago

phantom2152 commented 2 years ago

Hey ,

I am used to using jinja2 and flask in python so I opted for nunjucks when I started doing a web-project in node. But the problem is whenever I change something in the template files the changes will not appear on the browser on page refresh but instead I have to manually restart the server every time.

Is there any specific configuration should I use

I have configured nunjucks as below

//nunjucks
app.engine("views", nunjucks.render);
app.set("view engine", "html");
nunjucks.configure("views", {
  autoescape: true,
  express: app,
});

I am also using nodemon .

BobbyWibowo commented 2 years ago

noCache option in configure(), https://mozilla.github.io/nunjucks/api.html#configure

I usually have it set as process.env.NODE_ENV === 'development' to enable it only during development

ogonkov commented 2 years ago

There is also watch option available.