'Angular ng build --watch in Remote containers and Remote WSL not detecting file changes

The command ng build --watch does not appear to be working (detecting file changes) when developing an Angular project remotely (using Remote WSL and/or Remote containers) in Visual Studio Code.

Is this a known problem? Any workarounds?



Solution 1:[1]

Since posting I have found a solution/workaround using the --poll switch.

From comment made by https://github.com/JSMike at https://github.com/angular/angular-cli/pull/1814#issuecomment-241854816

In cases where Angular CLI is running in a shared directory on linux VM on a windows host the webpack dev server isn't detecting file changes from the host environment. (ex: Whenever a docker dev environment is running on a windows host.) This is solved by adding poll option to the webpack dev server configuration. By default when no poll interval is set watchpack will use native file system change detection. This change allows for setting the poll interval which will turn on polling.

Modify your package.json by adding the --poll 500 option.

Depending on your workflow/needs, add the --poll ms switch where ms is the polling interval.

"start": "ng serve --poll 500",
"watch": "ng build --watch --poll 500 --configuration development",

Further details can be found at the links below.

docker-container-doesnt-reload-angular-app

what-is-the-function-of-poll-flag-in-cli

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1