Webpack.js.org: Suppress warnings in console

Created on 7 Sep 2016  路  7Comments  路  Source: webpack/webpack.js.org

_From @natew on March 15, 2015 0:18_

We do dynamic route requires in a library that's used by people, and a lot of them are confused by this messaging:

WARNING in ./app/routes.js
Critical dependencies:
25:16-23 require function is used in a way, in which dependencies cannot be statically extracted

Beyond some sort of console.log override, is there a way to suppress this warning even if only in the server-side output?

_Copied from original issue: webpack/webpack#887_

Migrated

Most helpful comment

This has actually been possible for a while, but it just hadn't been documented.

You can find the documentation here.

tl;dr:

stats: {
  warnings: false
}

in the "root" of your webpack config, OR if you are using webpack-dev-server, in the devServer object.

All 7 comments

_From @dnutels on May 26, 2016 6:46_

Is there no response? At all?

Having the ability to control the tool's logging level/output seems instrumental, yet there is currently no way to show only errors, while skipping (or folding) warnings...

_From @jorilallo on June 5, 2016 1:6_

I would like to see a way to suppress warnings as well. As per #1617 many popular libraries (e.g. Quill, localforage) come build with Browserify, I don't really see the point of repackaging them and installing random loaders in the process. I would much rather use the original if it works and not see the warning contantly.

This has actually been possible for a while, but it just hadn't been documented.

You can find the documentation here.

tl;dr:

stats: {
  warnings: false
}

in the "root" of your webpack config, OR if you are using webpack-dev-server, in the devServer object.

Is there a way to do this from the CLI?

@SpaceK33z is there a way to only suppress warnings on a certain line?

I have server code that runs from webpack bundle in prod and straight from babel-node in dev, and I want to suppress the dynamic require warning only for this file.

  if (typeof __WEBPACK__ !== 'undefined') {
    // flow-issue(toy-factory-tracker)
    const requireMigration = require.context('../migrations/', false, /\.js$/)
    migrations = requireMigration.keys().map(requireMigration)
  } else {
    migrations = (await promisify(glob)(path.resolve(__dirname, '..', 'migrations', '*.js'))).map(require)
  }

@SpaceK33z please update documentation reference link, currently the link to the answer 404's

@Kielan here you go:

https://webpack.js.org/configuration/stats/

(I fixed the link in @SpaceK33z comment as well)

Was this page helpful?
0 / 5 - 0 ratings