Ray Booysen
Ray Booysen

Reputation: 30031

Webpack - Determine why a file is included

I have a webpack config with some loaders and plugins. These loaders have some include/test/exclude rules.

However, a set of files keep being included in the webpack build. They're not imported anywhere which means it's likely some bad config.

Is there a way to ask webpack WHY a file is included in a build?

Upvotes: 9

Views: 2714

Answers (2)

zgreen
zgreen

Reputation: 4708

Without knowing more about what set of files are being included, I'd suggest setting:

stats: 'verbose'

in your webpack config. Depending on the size of your app, this may dump a lot of info, but it should display where a given file or files is/are being included from. The stats config object can also be tailored to display more specific info.

Upvotes: 3

elbecita
elbecita

Reputation: 2664

There are some Display Options you can set when running webpack that can help you with what you want to achieve. Check them here.

There is a specific one, --display-reasons that will show the reasons why a module is included, or at least more information about why it is included. Also this one: --display-modules may be interesting to show modules that are hidden from the output by default because they come from directories like node_modules or bower_components.

I hope this helps.

Upvotes: 3

Related Questions