Webpack: silence output

2019-01-31 05:27发布

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.


Edit: I'm thinking this may not be possible, so I've created an issue on github: https://github.com/webpack/webpack/issues/1191

9条回答
疯言疯语
2楼-- · 2019-01-31 05:53

You've got the --display option that enables you to choose a level of information quantity you want displayed.

From webpack --help:

--display: Select display preset
[string] [choices: "", "verbose", "detailed", "normal", "minimal", "errors-only", "none"]

If you want to configure the informations displayed more precisely, you can also configure your webpack with the stats field in your webpack.config.js.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-31 05:54

I don't know when this feature was added, but I just noticed in the docs that you can add a webpackMiddleware property and on that you can specify noInfo: true. Doing this removes all the noise! But you still see output when there are errors. Yay!

查看更多
时光不老,我们不散
4楼-- · 2019-01-31 06:05

If you're using the Webpack API directly, and you're calling stats.toString(), then you can pass parameters to keep down the noise:

webpack(config).watch(100, (err, stats) => {
  console.log(stats.toString({chunks: false}))
})
查看更多
登录 后发表回答