feature request: silence output using config

I originally asked this as a question on StackOverflow but the lack of response and some digging has lead me to believe that this is not possible. Here’s the original question (copy/paste):

I would like to know if there’s a configuration option to tell webpack to only log the “important information” to the terminal. Pretty much just errors and warnings, not all of this:

output of terminal with webpack

There’s just so much output! Would love to suppress the common stuff and only have webpack output the warnings/errors. Would like a solution for webpack, webpack-dev-server, and karma-webpack.

Note: I tried noInfo: true and quiet: true but that didn’t seem to do the trick.

I’ve dug around the code a bit and I don’t think that there’s anything in webpack or webpack-core to silence the output based on the config I give it (though it looks like webpack-dev-server does support this). I would really like to silence output for my tests so I can keep noise to a minimum.

Note: Keeping webpack: bundle is now VALID or INVALID I think would still be valuable. It’s just the info about everything that was built is noisy.

Author: Fantashit

17 thoughts on “feature request: silence output using config

  1. For others looking at this, I actually prefer configuring it in my webpack config and I also prefer the 'errors-only' option. So my webpack config has this:

    {
      devServer: {
        stats: 'errors-only',
      },
    }

    Thanks!

  2. Here’s the relevent code. Looks like the acceptable preset values are: none, errors-only, minimal, normal, verbose and otherwise you can specify your own object:

    {
        hash: false,
        version: false,
        timings: false,
        assets: false,
        chunks: false,
        modules: false,
        reasons: false,
        children: false,
        source: false,
        errors: false,
        errorDetails: false,
        warnings: false,
        publicPath: false
    }
  3. stats: 'errors-only' works for me when using WebPackDevServer:
    new WebpackDevServer(webpack(webpackConfig), { stats: 'errors-only' })

  4. For anyone looking to silence the verbose output in the Relay examples (like relay-treasurehunt), this worked for me:

    1. open “server.js”
    2. search for “stats: {colors: true}”
    3. change it to “stats: {chunks:false}”
  5. Is there a way to supress all these messages also for webpack (and not just for webpack-dev-server)? I tried the ones above and they didn’t help.

  6. @IAMtheIAM I tried it, but it helps only for the dev server, not the build.

    EDIT: 30 minutes into reading the source code, I was able to disable it with the --hide-modules CLI option. Using webpack 1.13.0.

  7. @ebenoist in your entry karma.config.js try this:

    files: [ ... ],
    plugins: [ ... ],
    ...
    webpackMiddleware: {
      stats: {
        chunks: false,
      },
    },

    Note that you can use all the options @IAMtheIAM mentioned above. Hope this helps.

  8. @mjw56 thanks this is exactly what I needed. I didn’t realized I’d have to configure the middleware in this case. I appreciate your help!

  9. The above options didn’t work for me on latest, I needed to add maxModules: 0

    This is nearly silencing output for me:

    stats: {
                assets: false,
                cached: false,
                cachedAssets: false,
                children: false,
                chunks: false,
                chunkModules: false,
                chunkOrigins: false,
                colors: false,
                depth: false,
                entrypoints: false,
                errors: true,
                errorDetails: true,
                hash: false,
                maxModules: 0,
                modules: false,
                performance: false,
                providedExports: false,
                publicPath: false,
                reasons: false,
                source: false,
                timings: false,
                usedExports: false,
                version: false,
                warnings: false 
    }
  10. This isn’t fully working for me.

    Even after setting stats: 'none', I’m still getting the following outputted:

    Project is running at http://0.0.0.0:8080/
    webpack output is served from /
    

    I really really want to suppress this, because I’m hosting webpack-dev-server in a docker container, which maps the port to a different port, and I don’t want to confuse the user by printing two different port numbers to the output.

    Is this worthy of an issue?

  11. KARMA config, you can set webpackMiddleware.logLevel options to silent, it work for me.

    Here is version info:

    "karma-webpack": "^3.0.0"
    "webpack": "^4.9.1"
    

    Here is karma config:

    const base = require('./karma.base.conf')
    
    module.exports = function (config) {
      config.set(Object.assign(base, {
        reporters: ['mocha', 'coverage'],
        coverageReporter: {
          reporters: [{
            type: 'lcov',
            dir: '../coverage',
            subdir: '.'
          },
          {
            type: 'text-summary',
            dir: '../coverage',
            subdir: '.'
          }]
        },
        LogLevel: config.LOG_DISABLE,
        webpackMiddleware: {
          logLevel: 'silent'
        },
        singleRun: true,
        plugins: base.plugins.concat([
          'karma-coverage',
          'karma-chrome-launcher'
        ])
      }))
    }

Comments are closed.