Reputation: 576
I have a question regarding the Uglify JS
module, in the usecase of webpack plugin.
My codebase have several console.log
statements around the code for debugging purposes localy, it will only be printede out in development mode, but they are still taking up space in the codebase and i dont what them in the production build but, i would like to keep my console.error
and console.warn
still.
I know the Uglify JS
have key drop_console
flag but that kills every console output there is and i still want the warnings and errors in my console.
The reason for this question is i have a custom error handler than ships errors to Sentry, and I want to read the error in the console when it happens, so i use the error and warning console out put.
Upvotes: 2
Views: 1581
Reputation: 3458
From docs:
drop_console
(default:false
) -- Passtrue
to discard calls toconsole.*
functions. If you wish to drop a specific function call such asconsole.info
and/or retain side effects from function arguments after dropping the function call then usepure_funcs
instead....
pure_funcs
(default:null
) -- [...] You can passpure_funcs: [ 'Math.floor' ]
to let it know that this function won't produce any side effect, in which case the whole statement would get discarded.
So the option you're looking for is pure_funcs: [ 'console.log' ]
Upvotes: 4