- Notifications
You must be signed in to change notification settings - Fork9k
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. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
License
webpack/webpack
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Webpack is a module bundler. Its 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.
Install with npm:
npm install --save-dev webpack
Install with yarn:
yarn add webpack --dev
Webpack is a bundler for modules. The main purpose is to bundle JavaScriptfiles for usage in a browser, yet it is also capable of transforming, bundling,or packaging just about any resource or asset.
TL;DR
- BundlesES Modules,CommonJS, andAMD modules (even combined).
- Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
- Dependencies are resolved during compilation, reducing the runtime size.
- Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
- Highly modular plugin system to do whatever else your application requires.
Check out webpack's quickGet Started guide and theother guides.
Webpack supports all browsers that areES5-compliant (IE8 and below are not supported).Webpack also needsPromise
forimport()
andrequire.ensure()
. If you want to support older browsers, you will need toload a polyfill before using these expressions.
Webpack has arich plugininterface. Most of the featureswithin webpack itself use this plugin interface. This makes webpack veryflexible.
Name | Status | Install Size | Description |
---|---|---|---|
mini-css-extract-plugin | Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. | ||
compression-webpack-plugin | Prepares compressed versions of assets to serve them with Content-Encoding | ||
html-webpack-plugin | Simplifies creation of HTML files (index.html ) to serve your bundles | ||
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 bundleany static resource way beyond JavaScript. You can easilywrite your ownloaders using Node.js.
Loaders are activated by usingloadername!
prefixes inrequire()
statements,or are automatically applied via regex from your webpack configuration.
Name | Status | Install Size | Description |
---|---|---|---|
val-loader | Executes code as module and considers exports as JS code |
Name | Status | Install Size | Description |
---|---|---|---|
Loads and transpiles a CSON file |
Name | Status | Install Size | Description |
---|---|---|---|
Loads ES2015+ code and transpiles to ES5 usingBabel | |||
Loads TypeScript like JavaScript | |||
Loads CoffeeScript like JavaScript |
Name | Status | Install Size | Description |
---|---|---|---|
Exports HTML as string, requires references to static resources | |||
Loads Pug templates and returns a function | |||
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 usingPostHTML | |||
Compiles Handlebars to HTML |
Name | Status | Install Size | Description |
---|---|---|---|
<style> | Add exports of a module as style to DOM | ||
Loads CSS file with resolved imports and returns CSS code | |||
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 usingPostCSS |
Webpack uses async I/O and has multiple caching levels. This makes webpack fastand incrediblyfast on incremental compilations.
Webpack supports ES2015+, CommonJS and AMD modulesout of the box. It performs clever staticanalysis on the AST of your code. It even has an evaluation engine to evaluatesimple expressions. This allows you tosupport most existing libraries out of the box.
Webpack allows you to split your codebase into multiple chunks. Chunks areloaded asynchronously at runtime. This reduces the initial loading time.
Webpack can do many optimizations toreduce the output size of yourJavaScript by deduplicating frequently used modules, minifying, and givingyou full control of what is loaded initially and what is loaded at runtimethrough code splitting. It can also make your code chunkscachefriendly by using hashes.
We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone. We have avibrant ecosystem that spans beyond this single repo. We welcome you to check out any of the repositories inour organization orwebpack-contrib organization which houses all of our loaders and plugins.
Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:
- Documentation updates, enhancements, designs, or bugfixes
- Spelling or grammar fixes
- README.md corrections or redesigns
- Adding unit, or functional tests
- Triaging GitHub issues -- especially determining whether an issue still persists or is reproducible.
- Searching #webpack on twitter and helping someone else who needs help
- Teaching others how to contribute to one of the many webpack's repos!
- Blogging, speaking about, or creating tutorials about one of webpack's many features.
- Helping others in our webpackgitter channel.
- The Contributor's Guide to webpack
To get started have a look at ourdocumentation on contributing.
If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow thex-loader
,x-webpack-plugin
naming convention.
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always theeasiest entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
If you're just getting started, take a look atour new docs and concepts page. This has a high level overview that is great for beginners!!
If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.
For information about the governance of the Node.js project, seeGOVERNANCE.md.
- alexander-akait -Alexander Akait <sheo13666q@gmail.com> (he/him)
- evenstensberg -Even Stensberg <evenstensberg@gmail.com> (he/him)
- ovflowd -Claudio Wunder <cwunder@gnome.org> (he/they)
- snitin315 -Nitin Kumar <snitin315@gmail.com> (he/him)
- thelarkinn -Sean Larkin <selarkin@microsoft.com> (he/him)
- jhnns -Johannes Ewald <mail@johannesewald.de>
- sokra -Tobias Koppers <jackworks@protonmail.co>
- spacek33z -Kees Kluskens <kees@webduck.nl>
- TheLarkInn -Sean T. Larkin <selarkin@microsoft.com>
Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.
This is how we use the donations:
- Allow the core team to work on webpack
- Thank contributors if they invested a large amount of time in contributing
- Support projects in the ecosystem that are of great value for users
- Support projects that are voted most (work in progress)
- Infrastructure cost
- Fees for money handling
Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.
Become a gold sponsor and get your logo on our README on GitHub with a link to your site.
Become a silver sponsor and get your logo on our README on GitHub with a link to your site.
Become a bronze sponsor and get your logo on our README on GitHub with a link to your site.
Become a backer and get your image on our README on GitHub with a link to your site.
(In chronological order)
- @google forGoogle Web Toolkit (GWT), which aims to compile Java to JavaScript. It features a similarCode Splitting as webpack.
- @medikoo formodules-webmake, which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, theCode Splitting issue is still open (thanks also to @Phoscur for the discussion).
- @substack forbrowserify, which is a similar project and source for many ideas.
- @jrburke forrequire.js, which is a similar project and source for many ideas.
- @defunctzombie for thebrowser-field spec, which makes modules available for node.js, browserify and webpack.
- @sokra for creating webpack.
- Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction.
- All past and current webpack maintainers and collaborators.
- Everyone who has written a loader for webpack. You are the ecosystem...
- Everyone not mentioned here but that has also influenced webpack.
About
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. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.