4

For some reason, the nest start --watch is not watching any non-typescript assets. Even though I've followed exactly what this doc said: https://docs.nestjs.com/cli/monorepo#assets I can't seem to figure this out. I've tried in standard mode and mono-repo mode to no success. I started a new project just to demonstrate what I'm seeing.

Nest --version: 7.5.1

When running command: npm run start:dev I would expect to see that every time I update my html files, then I should see the "incremental file change detected" message and the app reloads but nothing is happening after the initial app load. On initial app load, the files do get copied to the dist folder so thats fine but I would expect that as I'm developing and updating these files, the app should also be reloading but it only seems to work for typescript files. Am I misunderstanding what this should be doing?

Here's the nest-cli.json:

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions":{
    "assets": ["**/*.html"],
    "watchAssets": true
  }
}

Any ideas??

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Lat
  • 63
  • 1
  • 4

2 Answers2

6

Your assets configuration seems to be wrong, try passing an object to the array as they do in the documentation:

"assets": [
  { "include": "**/*.html", "watchAssets": true }
]
eol
  • 23,236
  • 5
  • 46
  • 64
  • 2
    Thanks but I had already tried that as well and it still didn’t work. – Lat Nov 04 '20 at 05:07
  • Weird, it works fine for me. Is your project on github or something where I could take a closer look? – eol Nov 04 '20 at 08:17
  • 1
    Ah I figured out the problem. It looks like its related to my IDE. I'm using Visual Studio Code and noticed that when I save my file in that IDE, its not triggering the change for some reason. I edited the html file in VIM and that indeed does trigger the watch to register that the file changed and it reloads correctly. Visual Studio Code appears to be saving my file to disk when I check diffs and timestamps to ensure but for some reason its not triggering the watch. Either way, Nest is working properly with the config above - thank you! – Lat Nov 05 '20 at 12:56
2

Assets configuration works as described in documentation. VS Code wasn’t registering file changes so I proved it by manually editing a file outside or the IDE and it works. Closing question

Lat
  • 63
  • 1
  • 4