Skip to content

How to quiet the console.log outputs?  #79

Closed

Description

@volkanunsal

This kind of output in the browser console is really hard to work with. Can I disable these outputs?

[HMR] App is up to date.
[WDS] App updated. Recompiling...
[WDS] App hot update...
[HMR] Checking for updates on the server...

Activity

  1. gaearon commented on Feb 14, 2015

    @gaearon
    Owner

    You can copy paste webpack/hot/only-dev-server to your project, strip logs from it and use your version instead.

    Closing, let me know if I missed something!

  2. steida commented on Feb 14, 2015

    @steida
    Contributor

    Silent option in configuration would be nice.

  3. gaearon commented on Feb 14, 2015

    @gaearon
    Owner

    It's not really something we can control in RHL. You can file an issue with Webpack.

  4. pburtchaell commented on Feb 15, 2015

    @pburtchaell

    It's a bit hacky, but I currently have this and it helps by clearing the console of old logs after each refresh:

    if (WEB_ENV === 'development') {
      console.clear();
    }
    

    The WEB_ENV variable is set by WebPack in the config.

  5. gaearon commented on Feb 15, 2015

    @gaearon
    Owner

    I'd use if ('production' !== process.env.NODE_ENV) in this case.
    You'd need to set it to true using DefinePlugin for production anyway so React is properly compressed.

  6. roman-orlovskiy commented on Dec 1, 2016

    @roman-orlovskiy

    How disable console.log for webpack/hot/only-dev-server ??

    const server = new WebpackDevServer(compiler, { stats: {colors: true}, hot: true, clientLogLevel: 'none', //quiet: true, watchOptions: { ignored: /node_modules/ } /* historyApiFallback: { index: '/' }*/ });

    quiet: true not working!

  7. tavurth commented on Apr 22, 2017

    @tavurth

    Add this to your apps index.js:

    // Clear after module reload
    window.addEventListener('message', e => {
        if ('production' !== process.env.NODE_ENV) {
            console.clear();
        }
    });

    For example, this is part of my index.jsx entry point:

    ...
    
    const render = Component => {
        ReactDOM.render(
            <Provider store={store}>
                <MuiThemeProvider className='full-size'>
                    <Component />
                </MuiThemeProvider>
            </Provider>,
            document.getElementById('root')
        );
    };
    
    render(App);
    
    if (module.hot) {
        module.hot.accept();
    
        window.addEventListener('message', e => {
            if ('production' !== process.env.NODE_ENV) {
                console.clear();
            }
        });
    }

    if (module.hot) will get culled out when we run production minification, and every time HMR reloads, we'll clear the console.

  8. leongaban commented on May 10, 2017

    @leongaban

    This is really annoying, could anyone tell me where these logs are located in the react-hot-reload folder? Did not see them.

  9. tavurth commented on May 11, 2017

    @tavurth

    @leongaban They're sprinkled liberally througout the code.
    Go to your /node_modules/webpack folder and run a search and replace:

    find . -type f -name "*.js" -exec sed -i '' 's/console.log.*$//g' {} \;
    
  10. leongaban commented on May 11, 2017

    @leongaban

    @tavurth ah thanks! I was looking in the react-hot-reload folder.

  11. tavurth commented on May 11, 2017

    @tavurth
  12. peteobrien commented on Oct 30, 2017

    @peteobrien

    A quick way to silencing could be filtering in devtools with regex. i.e. ~ /^((?!(\[HMR|\[WDS)).)*$/
    UPDATE: in chrome 62 we can simply use -HMR -WDS

  13. tofilagman commented on Apr 12, 2018

    @tofilagman

    Add this to your apps index.js or index.ts:

    var _log = console.log;
     
    console.log = function () {
        if (arguments[0].indexOf('[HMR]') == -1) //remove hmr logging
            return _log.apply(console, arguments);
    };
    
  14. lorenzomigliorero commented on May 8, 2018

    @lorenzomigliorero

    Import log module directly in your bundle, and change logLevel:

    import { setLogLevel } from 'webpack/hot/log';
    setLogLevel('none');
    
  15. geiszla commented on Oct 18, 2018

    @geiszla

    For those who can't make it work with import { setLogLevel } from 'webpack/hot/log', see this comment: webpack/webpack#6265 (comment)

  16. IAMtheIAM commented on Nov 29, 2018

    @IAMtheIAM

    Hey guys, none of these suggestions worked for me, except the CLI option does!!

    webpack --client-log-level warning
    // or 
    webpack --client-log-level error
    

    It defaults to info which is where all the [HMR] and [WDS] spam comes from.

  17. jwld commented on Mar 21, 2019

    @jwld

    You can also just set clientLogLevel in your webpack devServer config:

    devServer: {
      clientLogLevel: 'none'
    }
    

    https://webpack.js.org/configuration/dev-server/#devserverclientloglevel

  18. fenok commented on May 22, 2019

    @fenok

    If you're using webpack-hot-middleware, you can configure it like this: webpack-hot-middleware/client?reload=true&noInfo=true

  19. agrublev commented on Jul 28, 2019

    @agrublev

    Webpack config

    devServer: {
            clientLogLevel: "silent",
    

    image

  20. elliotberry commented on Jan 20, 2021

    @elliotberry

    I love you guys. Finally found this thread after raging hard for like two years

  21. peterbartos commented on Jun 1, 2022

    @peterbartos

    In the current version the config is:

    devServer: {
        client: { logging: 'none' }
    }
    

    https://webpack.js.org/configuration/dev-server/#logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions