webpack/webpack-dev-server

Option to console.log only important stuff

steida opened this issue · 14 comments

It is planned or should I send PR?

We don't care about these messages:

[HMR] Waiting for update signal from WDS...
client:14 [WDS] Hot Module Replacement enabled.

There should be an option (default) to log only warnings and errors.

+1

I agree the following are not useful logs and they are cluttering up my console making it more difficult to sort through and find my own logs.

[WDS] App updated. Recompiling...
[WDS] Nothing changed.

There should be some way for me to disable these logs. This same issue was filed on the react-hot-loader, but it is apparently a webpack issue (gaearon/react-hot-loader#79).

Would like this option as well. The logs are a bit verbose after everything is setup correctly.

👍

+1 as well

As a very messy temporary work around, I have a script, development.js which i conditionally append to the entry in webpack.config.js.

"use strict";

// This is a workaround used alongside the webpack-dev-server hot-module-reload feature
//  - it's quite chatty on the console, and there's no currently no configuration option
//    to silence it. Only used in development.
// Prevent messages starting with [HMR] or [WDS] from being printed to the console
(function(global) {
    var console_log = global.console.log
    global.console.log = function() {
        if (!(
            arguments.length == 1 &&
            typeof arguments[0] === 'string' &&
            arguments[0].match(/^\[(HMR|WDS)\]/)
        )) {
            console_log.apply(global.console,arguments)
        }
    }
})(window)

It overloads console.log - skipping any messages starting with [HMR] or [WDS]. It does the job - the fact that it's only used in development eases my discomfort at its horridness :-)

Can you guys check if PR #579 works for you? Looking for feedback!

PR #579 was merged, check that out for more info. Note that it hasn't been released yet.

Released in 2.1.0-beta.3.

Thanks for this @SpaceK33z

Hi
Out of nothing, I started seeing these messages in my terminal every time I update a file:

webpack built c6aa9a16a68277967229 in 3390ms
webpack built 3fdedc302da408daa8dd in 341ms

I narrowed it down to realize it only happens when I have webpackHotMiddleware enabled, even if I have noInfo: true, quiet: true set.

Any idea?

al6x commented

Same issue, still see the logs with noInfo: true, quiet: true

Thought it was bad form to leave console.log() lines in your production code...