|
9 | 9 | import { BuilderContext } from '@angular-devkit/architect';
|
10 | 10 | import { existsSync } from 'node:fs';
|
11 | 11 | import path from 'node:path';
|
12 |
| -import { BuildOutputFileType } from '../../tools/esbuild/bundler-context'; |
| 12 | +import { BuildOutputFile, BuildOutputFileType } from '../../tools/esbuild/bundler-context'; |
13 | 13 | import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
14 | 14 | import { shutdownSassWorkerPool } from '../../tools/esbuild/stylesheets/sass-language';
|
15 | 15 | import { logMessages, withNoProgress, withSpinner } from '../../tools/esbuild/utils';
|
@@ -327,8 +327,7 @@ function* emitOutputResults(
|
327 | 327 | if (needFile) {
|
328 | 328 | if (file.path.endsWith('.css')) {
|
329 | 329 | hasCssUpdates = true;
|
330 |
| - } else if (!/(?:\.m?js|\.map)$/.test(file.path)) { |
331 |
| - // Updates to non-JS files must signal an update with the dev server |
| 330 | + } else if (!canBackgroundUpdate(file)) { |
332 | 331 | incrementalResult.background = false;
|
333 | 332 | }
|
334 | 333 |
|
@@ -422,3 +421,15 @@ function* emitOutputResults(
|
422 | 421 | function isCssFilePath(filePath: string): boolean {
|
423 | 422 | return /\.css(?:\.map)?$/i.test(filePath);
|
424 | 423 | }
|
| 424 | + |
| 425 | +function canBackgroundUpdate(file: BuildOutputFile): boolean { |
| 426 | + // Files in the output root are not served and do not affect the |
| 427 | + // application available with the development server. |
| 428 | + if (file.type === BuildOutputFileType.Root) { |
| 429 | + return true; |
| 430 | + } |
| 431 | + |
| 432 | + // Updates to non-JS files must signal an update with the dev server |
| 433 | + // except the service worker configuration which is special cased. |
| 434 | + return /(?:\.m?js|\.map)$/.test(file.path) || file.path === 'ngsw.json'; |
| 435 | +} |
0 commit comments