-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): watch index file when running bui…
…ld in watch mode Since the index augmentation happens outside of Webpack previously the index html was not being watched during watch mode. Closes #23851 (cherry picked from commit 130975c)
- Loading branch information
1 parent
5405a9b
commit 3afd784
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ages/angular_devkit/build_angular/src/builders/browser/tests/behavior/index_watch_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { concatMap, count, take, timeout } from 'rxjs/operators'; | ||
import { BUILD_TIMEOUT, buildWebpackBrowser } from '../../index'; | ||
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "index is updated during watch mode"', () => { | ||
it('index is watched in watch mode', async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
watch: true, | ||
}); | ||
|
||
const buildCount = await harness | ||
.execute() | ||
.pipe( | ||
timeout(BUILD_TIMEOUT), | ||
concatMap(async ({ result }, index) => { | ||
expect(result?.success).toBe(true); | ||
|
||
switch (index) { | ||
case 0: { | ||
harness.expectFile('dist/index.html').content.toContain('HelloWorldApp'); | ||
harness.expectFile('dist/index.html').content.not.toContain('UpdatedPageTitle'); | ||
|
||
// Trigger rebuild | ||
await harness.modifyFile('src/index.html', (s) => | ||
s.replace('HelloWorldApp', 'UpdatedPageTitle'), | ||
); | ||
break; | ||
} | ||
case 1: { | ||
harness.expectFile('dist/index.html').content.toContain('UpdatedPageTitle'); | ||
break; | ||
} | ||
} | ||
}), | ||
take(2), | ||
count(), | ||
) | ||
.toPromise(); | ||
|
||
expect(buildCount).toBe(2); | ||
}); | ||
}); | ||
}); |