Repository navigation
Console.log is not removing while building the app with react router v7 #20780
Replies: 2 comments
|
First distinguish logs in generated client JS, generated server JS and build-tool output. A build minifier does not silence Vite or framework tooling itself. A documented alternative is explicit Terser minification ( build: {
minify: 'terser',
terserOptions: {
compress: { drop_console: true },
},
}Merge this into your existing configuration. For a framework with multiple build environments, confirm the effective client/server configs both receive it; SSR minification is disabled by default in Vite. Then inspect the generated JS rather than source-map originals. Dropping all console calls also drops errors/warnings and can remove evaluation of arguments, so logging calls must not contain essential side effects. Without your dependency versions and a small reproduction, I cannot confirm why the existing References: https://vite.dev/config/build-options.html#build-minify and https://terser.org/docs/options/#compress-options Prepared with AI assistance and checked against the linked documentation. I have not reproduced your original project locally. |
|
If this is Vite 8, build: {
rolldownOptions: {
output: {
minify: {
compress: { dropConsole: true, dropDebugger: true }
}
}
}
}On Vite 7 or older, your existing — |
Uh oh!
There was an error while loading. Please reload this page.
All reactions