A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Throug
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Throug
Install with npm:
npm install --save-dev webpackInstall with yarn:
yarn add webpack --devWebpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.
TL;DR
Check out webpack's quick Get Started guide and the other guides.
Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported).
Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.
Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack very flexible.
Webpack can generate HTML pages and extract CSS files itself, both experimental — see what that covers, and what still needs a plugin, for CSS and HTML.
| Name | Status | Install Size | Description |
|---|---|---|---|
| compression-webpack-plugin | Prepares compressed versions of assets to serve them with Content-Encoding | ||
| html-bundler-webpack-plugin | Renders a template (EJS, Handlebars, Pug) with referenced source asset files into HTML. | ||
| pug-plugin | Renders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug. |
Webpack enables the use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.
Loaders are activated by using loadername! prefixes in require() statements,
or are automatically applied via regex from your webpack configuration.
JavaScript, JSON and assets need no loader, and CSS and HTML have experimental built-in support — but preprocessors and template engines keep their loaders.
| Name | Status | Install Size | Description |
|---|---|---|---|
| Loads and transpiles a CSON file |
| Name | Status | Install Size | Description |
|---|---|---|---|
| Loads ES2015+ code and transpiles to ES5 using Babel | |||
| Loads TypeScript like JavaScript | |||
| Loads CoffeeScript like JavaScript |
| Name | Status | Install Size | Description |
|---|---|---|---|
| Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular | |||
| Compiles Markdown to HTML | |||
| Loads and transforms a HTML file using PostHTML | |||
| Compiles Handlebars to HTML |
| Name | Status | Install Size | Description |
|---|---|---|---|
| Loads and compiles a LESS file | |||
| Loads and compiles a Sass/SCSS file | |||
| Loads and compiles a Stylus file | |||
| Loads and transforms a CSS/SSS file using PostCSS |
|
unused default export not marked as unused, so isn't tree-shaken away
Circular hash dependency for hashed folder names
webpack stopped concatenating modules in Violentmonkey's sw.js since 5.110.2
ESM output bakes hashed chunk filenames into importing modules, defeating long-term caching (no opt-out)
CSS: @value replacement in keyframes/animation produces broken output
Rule with issuer is not applied when importing via require.context
Webpack-native parallelism to obviate the need for the (unmaintained?) parallel-webpack package
ModuleConcatenationPlugin bails out for modules in available parent chunks ("not in the same chunk")
Asset module binary files are stored in webpack cache
export in library works only for last entry module