Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): do not print `Angular is running …
Browse files Browse the repository at this point in the history
…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.
```

(cherry picked from commit 26456b9)
  • Loading branch information
alan-agius4 committed Sep 27, 2023
1 parent 660d849 commit 9333581
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ export async function setupServer(
}

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({
document: html,
route: pathnameWithoutServePath(url, serverOptions),
Expand All @@ -407,6 +415,9 @@ export async function setupServer(
inlineCriticalCss: false,
});

console.log = originalConsoleLog;
/* eslint-enable no-console */

return content;
});
}
Expand Down

0 comments on commit 9333581

Please sign in to comment.