-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Conditionally drop console messages from production build #9222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
@eddiemonge @ianschmitz what are your thoughts on this? I believe it addresses the concerns expressed in my earlier PR, and I think it would be a great improvement to CRA. Thanks in advance! |
This seems reasonable to me. Another way I know of doing this on a per project basis is to create a logging utility function that wraps console call somewhat like this:
If the env is production then the code is removed at build time. |
@iansu @amyrlam @mrmckeb @ianschmitz @petetnt Can you please take a look at this PR? I believe that this approach to removing console statements from production builds is easy, safe, maintainable, and very much desirable for end users. If there are further changes I can make to this PR to make it more acceptable and/or appealing, please let me know. I'm eager to get (or a functionally equivalent) change accepted. Thanks again! |
This PR would be welcomed by the community here |
Anything I can help with to progress this PR? My two cents... the code change is identical code style to the other environment checks such as shouldUseSourceMap. I took a look at the two failing checks, but there is no detail on why they failed. |
Just another note of support for this PR ... using the popular snippet |
Add a environment variable, `DROP_CONSOLE`, to specify if console function calls should be dropped in the production build.
93b5ed0
to
950e883
Compare
@ianschmitz @eddiemonge @mrmckeb @petetnt (and anyone else) can you please look at this PR? I believe it meets all requirements for a contribution and addresses an issue requested by CRA users. If there's anything I can do to move this along, please tell me - it's been a long time and I'd really like to see some progress (or at least feedback) on this PR. Thank you in advance! |
@ianschmitz Thanks for adding the tag |
Any ETA on this? Would be nice to have this implemented guys |
Bump |
Can someone please review this |
Another gentle nudge. Can someone from facebook (@ianschmitz ?) take a bit of time to approve / give feedback on this? It would be highly appreciated. Eject is not the way. |
Just a quick update on this, I still get upvotes on my response to this issue on StackOverflow and the issue has over 10K views. Seems like this is still a relevant topic for some people, personally I've given up on this ever being actioned, but would be nice to have some closure here one way or the other so we can all move on. https://stackoverflow.com/questions/47839311/removing-log-statements-in-create-react-app-without-ejecting/53770988#53770988 |
@jackblackevo @matrush @rvdende @danielrentz @sdarnadeem @pawelskowronek @nvh95 @JSLGeeganage and anyone else - can you please review this (simple) MR and let us know what needs to be done to merge it, or why it cannot be mergeable? |
Add a environment variable,
DROP_CONSOLE
, to specify if consolefunction calls should be dropped in the production build.
Supersedes #9221