Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I need to restart express server when I make a change to a swig template?

Normally, when using EJS templates with Express, I don't have to restart the server to see changes I've made to a template. I just make a change to a .ejs file and reload the browser to see my changes.

However, with swig templates (which I very much prefer over ejs), if I make a change to a .html file, I have to restart the server inorder to see my changes reflected in the browser.

Is this a bug, or just a side effect of something else I've overlooked?

I'm not looking for a tool like grunt watch, nodemon, or supervisor, I just want my swig templates to behave more like ejs templates if possible.

like image 585
Colyn Brown Avatar asked May 07 '13 00:05

Colyn Brown


1 Answers

As explained in the Swig API Documentation, you can configure Swig to not cache templates.

I use something similar to this:

swig.init({
  ..
  cache : app.get('env') === 'production',
  ..
});

This will make it only cache compiled templates in the production environment.

like image 110
robertklep Avatar answered Nov 13 '22 17:11

robertklep