Webpack
Webpack is a popular module bundler for JavaScript applications. Its job is to gather a project's scattered files — JS modules, stylesheets, images and other assets — and combine them into a small number of optimised packages that the browser can load quickly and efficiently.
How webpack works
Webpack analyses the code and builds a dependency graph: it starts from an entry point and follows every import to determine what is needed and in what order. It then transforms assets using loaders (for example compiling styles) and plugins (for example minification), and finally generates the output bundles. Along the way it often runs a transpiler to convert modern syntax into a form that older browsers understand.
Why all this matters
Without a bundler the browser would have to download dozens or hundreds of separate files, which slows loading. Webpack reduces the number of requests, removes unused code, splits the application into smaller chunks loaded on demand and optimises assets for performance. In practice it is installed and run through package managers such as npm or Yarn. Although newer build tools can be faster and simpler to configure, webpack remains very flexible and widely used, especially in large projects that require precise control over the build process. The choice of build tool affects compilation time, output size and the team's workflow, so in bigger projects it is treated as a deliberate architectural decision rather than a default setting.
Powiązane pojęcia
Najczęstsze pytania
How is webpack different from a transpiler?
A transpiler, such as Babel, translates code from one language version to another. Webpack is a bundler — it combines many modules and assets into packages, and it runs transpilation as one of its processing steps.
