Skip to content

Commit 450dd29

Browse files
committedNov 21, 2023
fix(@angular-devkit/build-angular): default to watching project root 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)
1 parent d998707 commit 450dd29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎packages/angular_devkit/build_angular/src/utils/environment-options.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,9 @@ export const useLegacySass: boolean = (() => {
100100
const debugPerfVariable = process.env['NG_BUILD_DEBUG_PERF'];
101101
export const debugPerformance = isPresent(debugPerfVariable) && isEnabled(debugPerfVariable);
102102

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

0 commit comments

Comments
 (0)
Please sign in to comment.