Mark Zhang
Mark Zhang

Reputation: 599

How to suppress built modules from webpack terminal output?

When using webpack2.x to build my project , the terminal console the build log like this:

Hash: d09758ddb088e1f8cd3b
Version: webpack 2.2.1
Time: 9450ms
                         Asset       Size  Chunks             Chunk Names
   app.d09758ddb088e1f8cd3b.js    28.7 kB       0  [emitted]  app
vendor.d09758ddb088e1f8cd3b.js     206 kB       1  [emitted]  vendor
style.d09758ddb088e1f8cd3b.css    1.89 kB       0  [emitted]  app
             index_bundle.html  852 bytes          [emitted]
   [1] ./~/vue/dist/vue.common.js 226 kB {1} [built]
[1] ./~/vue/dist/vue.common.js 226 kB {1} [built]
   [3] ./~/vue-loader/lib/component-normalizer.js 1.12 kB {0} [built]
   [4] ./~/process/browser.js 5.3 kB {1} [built]
   [5] ./~/lodash/lodash.js 540 kB {1} [built]
   [7] ./~/axios/index.js 40 bytes {1} [built]
   [8] ./~/vue-router/dist/vue-router.common.js 56.1 kB {1} [built]

How can I remove messages like ./~/vue/dist/vue.common.js 226 kB {1} [built] and get just this output:

Hash: d09758ddb088e1f8cd3b
Version: webpack 2.2.1
Time: 9450ms
                         Asset       Size  Chunks             Chunk Names
   app.d09758ddb088e1f8cd3b.js    28.7 kB       0  [emitted]  app
vendor.d09758ddb088e1f8cd3b.js     206 kB       1  [emitted]  vendor
style.d09758ddb088e1f8cd3b.css    1.89 kB       0  [emitted]  app
             index_bundle.html  852 bytes          [emitted]

Upvotes: 1

Views: 2105

Answers (4)

Pieter-Jan Van Robays
Pieter-Jan Van Robays

Reputation: 562

Since the --hide-modules seems to be removed, adding the following to your webpack.config.js:

stats: {
    modules: false
}

This option is documented here: Stats | webpack

Upvotes: 2

Digger2000
Digger2000

Reputation: 546

using webpack node.js API:

const compiler = webpack(config);

compiler.run((err, stats) => {
  if (err) {
    console.error(err.stack || err);
    if (err.details) console.error(err.details);
    process.exit(1);
  }

  process.stdout.write(stats.toString({
    chunks: false,
    colors: true
  }) + '\n');

  if (stats.hasErrors()) {
    process.exit(2);
  }
});

When using webpack CLI, you can try --hide-modules option.

Upvotes: 1

Michael Jungo
Michael Jungo

Reputation: 32982

You can use the stats option maxModules and set it 0 so it won't show any module built. This option is currently undocumented. In your webpack config add:

stats: {
  maxModules: 0
}

Theoretically you should be able to use modules: false and chunkModules: false but that does not appear to work with the webpack CLI, at least it works with the webpack-dev-middleware.


The option is now documented at Configuration - Stats.

Upvotes: 1

exoslav
exoslav

Reputation: 2295

Actually, there are plenty of options how to configurate your webpack cli output. You can set up it in stats object in your webbapck.config file. Unfortunately I was not able to find the option which hides the lines you want.

See Docs about setting up cli output

Upvotes: 0

Related Questions