0

I have many vite logs that are polluting my console in dev environment

[vite] connecting...
[vite] connected.
[vite] hot updated: /src/app.css

How to filter the logs done by vite ?

The only answer I found was negative filtering in the browser console, but I have to do this for every tab and at every restart of the browser

I also tried, to no effect : in vite.config.ts (it seems to clear the server console, not the browser's)

import { defineConfig } from 'vite'

export default defineConfig(() => {
  return {
    logLevel: 'error',
    // ...
  }
})

Also tried to no effect: https://stackoverflow.com/a/9216488/7333766 : it affects most logs but not vite logs

And https://stackoverflow.com/a/42651389/7333766: it disables all logs even not vite's and displays this message : The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.

And https://github.com/vitejs/vite/discussions/7920 that did not work as well

Eli O.
  • 1,543
  • 3
  • 18
  • 27

1 Answers1

0

I finally found a way:

Go into your node_modules\vite\dist\client\client.mjs

And comment those lines:

console.debug('[vite] connecting...');
// ...
console.debug(`[vite] connected.`);
// ...
console.debug(`[vite] css hot updated: ${searchUrl}`);
// ...
console.debug(`[vite] hot updated: ${loggedPath}`);
Eli O.
  • 1,543
  • 3
  • 18
  • 27