Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): default to watching project root …
Browse files Browse the repository at this point in the history
…on Windows with application builder

When using the `application` or `browser-esbuild` builder in watch mode on Windows, the project root
will now be watched by default. This provides a workaround for users of Visual Studio which uses a
file save mechanism that causes the watch mode to not correctly trigger. By watching the entire
project root, this problem is avoided. However, this may result in additional rebuilds due to changes
of unrelated files in the project root.
This behavior can be disabled using the environment variable `NG_BUILD_WATCH_ROOT=0`. On non-Windows
platforms, disabled is the default.

Addresses #26437

(cherry picked from commit 96b5b10)
  • Loading branch information
clydin committed Nov 21, 2023
1 parent d998707 commit 450dd29
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ export const useLegacySass: boolean = (() => {
const debugPerfVariable = process.env['NG_BUILD_DEBUG_PERF'];
export const debugPerformance = isPresent(debugPerfVariable) && isEnabled(debugPerfVariable);

// Default to true on Windows to workaround Visual Studio atomic file saving watch issues
const watchRootVariable = process.env['NG_BUILD_WATCH_ROOT'];
export const shouldWatchRoot = isPresent(watchRootVariable) && isEnabled(watchRootVariable);
export const shouldWatchRoot =
process.platform === 'win32'
? !isPresent(watchRootVariable) || !isDisabled(watchRootVariable)
: isPresent(watchRootVariable) && isEnabled(watchRootVariable);

0 comments on commit 450dd29

Please sign in to comment.