Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug webpack build performance?

Tags:

I'm trying to determine what is taking my webpack build so long. I'm struggling to find any logging options or debug options so webpack will log information about what its doing... I've looked around and seen a couple things like the noInfo: false option but that doesnt do anything for me...

I'm uing the node.js api. Here's an example:

var compiler = webpack(config)

compiler.run(function(err, stats) {
  if (err) {
    console.error(err)
    return
  } else {
    fs.writeFileSync(path.join(root, 'webpack', 'stats.'+projectName+'.json'), stats.toJson(), 'utf8')
    console.log("done: stats."+projectName+'.json')
  }
});
like image 659
Chet Avatar asked Oct 06 '15 20:10

Chet


People also ask

Why is my webpack build so slow?

Over the past eight years, webpack has become increasingly powerful. However, due to the additional packaging process, the building speed is getting slower as the project grows. As a result, each startup takes dozens of seconds (or minutes), followed by a round of build optimization.

How do I debug a webpack?

Click the "inspect" link under each script to open a dedicated debugger or the Open dedicated DevTools for Node link for a session that will connect automatically. You can also check out the NiM extension, a handy Chrome plugin that will automatically open a DevTools tab every time you --inspect a script.

Does webpack automatically minify?

Webpack v4+ will minify your code by default in production mode .


1 Answers

Although an old question, it's useful to know that new plugins have been released to help track down performance bottlenecks.

For example, you could try using something like the Speed Measure Webpack Plugin to see how long different loaders and plugins are taking to run in your configuration

like image 67
Anuj Avatar answered Oct 18 '22 17:10

Anuj