Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mustache-js views don't auto-refresh with nodemon

I've been using nodemon for a while to save me the trouble of restarting the server whenever I edit a file.

Now I switched to using mustache.js templates, and the magically-always-up-to-date ceased to work - I now need to manually restart the server for my changes to take effect.

Is this a bug? Misconfiguration?

To clarify: whenever I edit a .mustache file, I need to manually restart the server to see my changes.

like image 768
ripper234 Avatar asked Dec 26 '16 23:12

ripper234


2 Answers

From this answer I changed my start script to

"start": "nodemon -e js,mustache ./server.js",

like image 184
ripper234 Avatar answered Oct 26 '22 19:10

ripper234


In order to specify on which files Nodemon should auto-refresh, you can set package.json to start Nodemon with a nodemon.json configuration file, that includes the file extensions to watch. For example:

Add to package.json file:

  "scripts": {
    "dev": "nodemon --config nodemon.json"
  },

Create nodemon.json file:

{
    "verbose": true,
    "execMap": {
        "js": "node --harmony"
    },
    "script": "server.js",
    "ext": "js mustache"
}

Now when running, you should see that nodemon is watching for .js and .mustache files:

> npm run dev

[nodemon] 1.11.0
[nodemon] reading config nodemon.json
[nodemon] watching extensions: js,mustache 
[nodemon] starting `node --harmony server.js`
[nodemon] child pid: 7740
[nodemon] watching 5 files
like image 22
Noam Manos Avatar answered Oct 26 '22 20:10

Noam Manos