Reload server when editing frontend files?


#1

I am using Nunjucks to provide templating. However, when I edit my frontend .html files the server is not reloaded. This makes it difficult to test my templating changes.

There seems to be no way to force a reload, so I have taken to editing comments in the backend just to force a server reload and see my frontend changes. Is there a better way?


#2

Hi gids,

yes, you can create a watch.json with your custom watcher rules. For your use case, you might use this one, which includes the default rules and adds a “restart” rule for html files:

{
  "install": {
    "include": [
      "^package\\.json$",
      "^\\.env$"
    ]
  },
  "restart": {
    "exclude": [
      "^public/",
      "^dist/"
    ],
    "include": [
      "\\.html$",
      "\\.coffee$",
      "\\.js$",
      "\\.json$"
    ]
  },
  "throttle": 100
}

#3

Very helpful, thanks!