Webpack-dev-server: No respect, no respect at all! (for stats.warningsFilter 😉)

Created on 2 Nov 2018  Â·  11Comments  Â·  Source: webpack/webpack-dev-server

  • Operating System: mac OS Sierra 10.12.6
  • Node Version: 6.11.1
  • NPM Version: 3.10.10
  • webpack Version: 4.19.0
  • webpack-dev-server Version: 3.1.8
  • [x] This is a bug
  • [ ] This is a modification request

Code

webpack.config_.dev_.js

  //...
devServer: {
    host: '0.0.0.0',
    port: WEBPACK_PORT,
    watchOptions: {
      aggregateTimeout: 300,
      poll: true
    },
    stats: {
      assets: false,
      children: false,
      colors: true,
      version: false,
      hash: false,
      timings: true,
      chunks: false,
      chunkModules: false,
      warningsFilter: '[mini-css-extract-plugin]'
    },
    headers: {
      'Access-Control-Allow-Origin': '*'
    }

Webpack config stats docs I'm going off of:
https://webpack.js.org/configuration/stats/#stats

WDS stats docs:
https://webpack.js.org/configuration/dev-server/#devserver-stats-

Expected Behavior

While using stats.warningsFilter in my configuration, then it would be respected by webpack-dev-server, and that errors of anything from stats.warningsFilter would be filtered out and not posted to my browser's console. The closest to addressing logging that I can find in your code is this line, or several other lines that check for stats.colors from the same file.
Note: I _am_ certain that my stats are connected correctly, because setting my stats.colors to false turns the colors off.

Actual Behavior

When adding warningsFilter: '[mini-css-extract-plugin]' to my config, errors from Webpack-Dev-Middleware are respected, and I no longer see them:

[webpack] ℹ 「wdm」: Compiled with warnings.

However, I am still getting my warnings in the browser's console:

screen shot 2018-11-01 at 3 41 11 pm

Which is originating from https://github.com/webpack/webpack-dev-server/blob/55398b5de17b9a845b1ee5aaa90bb2002c25ddfb/client-src/default/index.js#L145

For Bugs; How can we reproduce the behavior?

Hmm I guess you'd need to set up a warning that you would try to filter out with your webpack config. Open browser console, errors persist with each page reload.

Note: when I update webpack-dev-server to latest version (3.1.10), problem still persists.

Thank you in advance!

4 (nice to have) patch 4 (inconvenient) bug

Most helpful comment

In near future

All 11 comments

@missalyss looks like a bug, feel free to investigate and send a PR

@evilebottnawi to your knowledge, does your client have access to webpack config at all? I've been trying to send it from bin/webpack-dev-server, but it doesn't want to read it.

@evilebottnawi

I have also encountered this problem, except the warnings are from a different loader (ts-loader).

Setting a proper stats.warningsFilter, as described in ts-loader doc, does eliminate the warning from terminal output, but not from browser console.

I found the root cause is browser console log is collected using a hard-coded stats option without consulting the stats option from config at all. See code at

Maybe we could fixed it by merging the hard-coded stats option with the one passed in constructor.

Should be fixed, but we need add test for warningsFilter option as described in original issue

@evilebottnawi I'm making the PR... totally forgot about that test.

@yoannmoinet will be great, thanks!

@evilebottnawi Thanks!
Do you know when there will be a release?

In near future

Thx for this @yoannmoinet ! Can't wait to get it!

Was this page helpful?
0 / 5 - 0 ratings