fix(@angular-devkit/build-angular): do not print Angular is running in development mode. in the server console when using dev-server

This commit disables logging `Angular is running in development mode.` when using SSR with vite dev-server. This to avoid polluting the server console with `Angular is running in development mode.` logs for each page load and reload.

Example:
```
ng s

Initial Chunk Files | Names         | Raw Size
main.js             | main          | 34.31 kB |
polyfills.js        | polyfills     | 95 bytes |
styles.css          | styles        | 95 bytes |

                    | Initial Total | 34.49 kB

Application bundle generation complete. [5.205 seconds]

  ➜  Local:   http://localhost:4200/
Watch mode enabled. Watching for file changes...
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
```
This commit is contained in:
Alan Agius 2023-09-27 12:07:06 +00:00 committed by Alan Agius
parent 6b5c469a42
commit 26456b93d5

View File

@ -450,6 +450,14 @@ export async function setupServer(
} }
transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, async (html) => { transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, async (html) => {
/* eslint-disable no-console */
const originalConsoleLog = console.log;
console.log = (...args) => {
if (args[0] !== 'Angular is running in development mode.') {
originalConsoleLog.apply(args);
}
};
const { content } = await renderPage({ const { content } = await renderPage({
document: html, document: html,
route: pathnameWithoutServePath(url, serverOptions), route: pathnameWithoutServePath(url, serverOptions),
@ -464,6 +472,9 @@ export async function setupServer(
inlineCriticalCss: false, inlineCriticalCss: false,
}); });
console.log = originalConsoleLog;
/* eslint-enable no-console */
return content; return content;
}); });
} }