Skip to content

Commit ff47713

Browse files
alan-agius4clydin
authored andcommitted
refactor(@angular-devkit/build-angular): update vite client code update script
In the latest version of vite the script changed. (cherry picked from commit d1367a0)
1 parent d9a00e2 commit ff47713

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,19 +309,17 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions):
309309
* @param file The absolute path to the Vite client code.
310310
* @returns
311311
*/
312-
async function loadViteClientCode(file: string) {
312+
async function loadViteClientCode(file: string): Promise<string> {
313313
const originalContents = await readFile(file, 'utf-8');
314-
const firstUpdate = originalContents.replace('You can also disable this overlay by setting', '');
315-
assert(originalContents !== firstUpdate, 'Failed to update Vite client error overlay text. (1)');
316-
317-
const secondUpdate = firstUpdate.replace(
318-
// eslint-disable-next-line max-len
319-
'<code part="config-option-name">server.hmr.overlay</code> to <code part="config-option-value">false</code> in <code part="config-file-name">${hmrConfigName}.</code>',
314+
const updatedContents = originalContents.replace(
315+
`h('br'), 'You can also disable this overlay by setting ', ` +
316+
`h('code', { part: 'config-option-name' }, 'server.hmr.overlay'), '` +
317+
` to ', h('code', { part: 'config-option-value' }, 'false'), ' in ', h('code', { part: 'config-file-name' }, hmrConfigName), '.'`,
320318
'',
321319
);
322-
assert(firstUpdate !== secondUpdate, 'Failed to update Vite client error overlay text. (2)');
320+
assert(originalContents !== updatedContents, 'Failed to update Vite client error overlay text.');
323321

324-
return secondUpdate;
322+
return updatedContents;
325323
}
326324

327325
function pathnameWithoutBasePath(url: string, basePath: string): string {

0 commit comments

Comments
 (0)