Skip to content

Commit d1367a0

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.
1 parent 0b8f53b commit d1367a0

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
@@ -306,19 +306,17 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions):
306306
* @param file The absolute path to the Vite client code.
307307
* @returns
308308
*/
309-
async function loadViteClientCode(file: string) {
309+
async function loadViteClientCode(file: string): Promise<string> {
310310
const originalContents = await readFile(file, 'utf-8');
311-
const firstUpdate = originalContents.replace('You can also disable this overlay by setting', '');
312-
assert(originalContents !== firstUpdate, 'Failed to update Vite client error overlay text. (1)');
313-
314-
const secondUpdate = firstUpdate.replace(
315-
// eslint-disable-next-line max-len
316-
'<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>',
311+
const updatedContents = originalContents.replace(
312+
`h('br'), 'You can also disable this overlay by setting ', ` +
313+
`h('code', { part: 'config-option-name' }, 'server.hmr.overlay'), '` +
314+
` to ', h('code', { part: 'config-option-value' }, 'false'), ' in ', h('code', { part: 'config-file-name' }, hmrConfigName), '.'`,
317315
'',
318316
);
319-
assert(firstUpdate !== secondUpdate, 'Failed to update Vite client error overlay text. (2)');
317+
assert(originalContents !== updatedContents, 'Failed to update Vite client error overlay text.');
320318

321-
return secondUpdate;
319+
return updatedContents;
322320
}
323321

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

0 commit comments

Comments
 (0)