Search code examples
javascriptbuildwebpackbuild-system

Webpack Library Output


How does Webpack know which files to include in library build? How does it know which files should not or should be included, as in miscellaneous files like images, examples, documentation, etc. If it automatically includes them how do we make Webpack ignore these included files?


Solution

  • Webpack scans the actual JS files themselves, starting at your entry point(s) and recursively scanning each referenced file, to determine what to build. It won't include any other files like examples or documentation unless you for some reason are include/requiring them from your javascript.

    Things like CSS/LESS/SASS and images are built with specific loaders which generally also only build referenced files.

    TL;DR: If it isn't explicitly included somewhere, it probably isn't in the build.