Skip to content

Use renderder GitHub pages links #2554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9d014e1
fix(guides) Removing webpack-command (#2454)
Aug 20, 2018
44a03e5
chore(concepts) Add name to the contribution (#2448)
debs-obrien Aug 20, 2018
f17cc9f
docs(cli) Remove webpack-command (#2447)
EugeneHlushko Aug 20, 2018
cd7e330
docs(guides) Updateb code splitting guide (#2427)
EugeneHlushko Aug 21, 2018
db81103
docs(guides) Update tree shaking guide, make syntax consistent (#2426)
EugeneHlushko Aug 22, 2018
c4237c5
docs(plugins) Update plugins configuration example (#2444)
EugeneHlushko Aug 22, 2018
fd3c835
docs(configuration) Update index.md (#2462)
jakoblind Aug 23, 2018
69c412b
docs(config) Optimization portableRecords doc (#2456)
EugeneHlushko Aug 23, 2018
ef9f510
docs(configuration) Remove array from possible values of Rule.sideEff…
FadySamirSadek Aug 24, 2018
1c9145c
docs(concepts) Update hot-module-replacement.md (#2442)
kryptokinght Aug 26, 2018
b96d505
docs(plugins) Add ProgressPlugin + progress reporting (#2293)
elliottsj Aug 26, 2018
e24bfb6
docs(configuration) Add caveat for using http-proxy-middleware option…
naomiajacobs Aug 26, 2018
8e1e8b1
docs(guides) Update code-splitting.md (#2153)
tiendo1011 Aug 26, 2018
21638f9
Merge branch 'rebuild' of https://github.com/webpack/webpack.js.org i…
budmc29 Aug 28, 2018
b1bf117
Create why-webpack
debs-obrien Aug 9, 2018
727817b
corrections
debs-obrien Aug 11, 2018
332500b
all corrections done
debs-obrien Aug 13, 2018
443ccf1
minor corrections to why webpack page
debs-obrien Aug 15, 2018
1aa804b
minor correction on why webpack page
debs-obrien Aug 15, 2018
e094151
modified github user name for contributions
debs-obrien Aug 15, 2018
fa66708
Rename why-webpack to why-webpack.md
debs-obrien Aug 16, 2018
6a1aee3
Update why-webpack.md
debs-obrien Aug 16, 2018
ad3f580
Update why-webpack.md
debs-obrien Aug 16, 2018
def878a
update why-webpack.md to fix travis build
debs-obrien Aug 16, 2018
926012b
update why-webpack.md grammatical review
debs-obrien Aug 16, 2018
218ba73
added names to contribution
debs-obrien Aug 22, 2018
f669f3f
Update why-webpack.md
debs-obrien Aug 28, 2018
cdf4ad6
fix(concepts) Update why-webpack.md (#2473)
debs-obrien Aug 28, 2018
49df953
fix(concepts) Removed duplicate sentence (#2475)
dorianturle Aug 29, 2018
58ff30d
docs(guides) Minor wording change (#2471)
GregTrevellick Sep 2, 2018
827608f
docs(guides) Correct main entry in package.json (#2479)
aletuan Sep 2, 2018
859a2c6
fix(plugins) Fix invalid splitChunks example (#2478)
chrisdothtml Sep 2, 2018
5468090
fix(guides) Fixed gramattical error (#2477)
simioluwatomi Sep 2, 2018
c54bcf9
docs(guides): Add warning about dev server (#2459)
GAumala Sep 2, 2018
726cf82
docs(configuration) Update minimal config example (#2482)
mlsteele Sep 2, 2018
54033a2
Merge branch 'rebuild' of https://github.com/webpack/webpack.js.org i…
budmc29 Sep 3, 2018
15b4a31
docs(guides) Update production.md (#2476)
simioluwatomi Sep 3, 2018
6244237
fix(concepts) Fix typo (#2485)
segmentationfaulter Sep 4, 2018
0ed0575
fix(guides) Fix reference to default (#2486)
Sep 5, 2018
aba7ebe
fix(concepts) Fixed link to `output` property (#2489)
m4jing Sep 6, 2018
5dd17f6
fix(contribute) Use consistent plugin name in code snippet (#2496)
franjohn21 Sep 10, 2018
7eb1f0c
fix(configuration) Fix small typo (#2511)
angelogulina Sep 13, 2018
2e774a3
docs(manifest) Corrections and small update to concept manifest page …
EugeneHlushko Sep 14, 2018
649ae3a
docs(concepts) Update dependency graph concepts page (#2495)
EugeneHlushko Sep 14, 2018
020d6b9
docs(concepts) Use common formatting, provide more links, mention mod…
EugeneHlushko Sep 16, 2018
11a245e
docs(configuration) Add externals examples (#2515)
zefman Sep 17, 2018
19ead0e
docs(plugins) Update Writing plugin and Plugin pattern page (#2200)
nveenjain Sep 18, 2018
1bde2df
docs(concepts) Using vendors as entry is not recommended (#2525)
sokra Sep 18, 2018
b9c586f
fix(guides) Correct misspelling and punctuation errors (#2513)
nimamehanian Sep 18, 2018
9e959d2
docs(plugins): Add custom vendor chunks using RegEx example (#2518)
sakhisheikh Sep 18, 2018
d09b3bf
chore(plugins) Remove space (#2527)
sakhisheikh Sep 18, 2018
a0c6b73
docs(plugins) Add .mjs to the defaults (#2493)
philipwalton Sep 18, 2018
db4ac5b
chore(plugins) Minor SplitChunks Documentation Clean Up (#2252)
jacobangel Sep 19, 2018
de80036
fix(api) Clarify module section (#2529)
shammellee Sep 20, 2018
b77b222
docs(plugins): Update links in htmlwebpackplugin (#2530)
sibiraj-s Sep 20, 2018
111fe93
docs(plugins) Fix reuseExistingChunk title nesting (#2526)
EugeneHlushko Sep 24, 2018
676844e
docs(guides) Fix typo (#2537)
sibiraj-s Sep 24, 2018
c8dd870
chore(guides) Import needs to be highlighted with '+' mark (#2536)
saiprasad2595 Sep 24, 2018
98c41e8
docs(config) Optimization moduleIds option (#2543)
EugeneHlushko Sep 26, 2018
9d26426
docs(config) Add comments and values for rule.type (#2541)
nerdkid93 Sep 27, 2018
10c6f31
docs(conceps) Adds JSON file to out of the box supported files (#2548)
farskid Sep 27, 2018
6b7653c
docs(guides) Update example webpack output in asset-management.md (#2…
venelinpetrov Sep 27, 2018
8aa8215
Merge branch 'master' of https://github.com/webpack/webpack.js.org in…
budmc29 Sep 27, 2018
60a4945
Merge branch 'rebuild' of https://github.com/webpack/webpack.js.org i…
budmc29 Sep 27, 2018
553e37b
Fix(utilities): Convert github raw links to rendered page links
budmc29 Sep 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/content/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ contributors:
- chenxsan
- rencire
- madhavarshney
- EugeneHlushko
related:
- title: Analyzing Build Statistics
url: https://survivejs.com/webpack/optimizing-build/analyzing-build-statistics/
Expand All @@ -23,11 +24,6 @@ related:

For proper usage and easy distribution of this configuration, webpack can be configured with `webpack.config.js`. Any parameters sent to the CLI will map to a corresponding parameter in the config file.

Users have a choice between two CLI packages:

* [webpack-cli](https://github.com/webpack/webpack-cli): the original webpack full-featured CLI.
* [webpack-command](https://github.com/webpack-contrib/webpack-command): the lightweight, opinionated and modern CLI.

Read the [installation guide](/guides/installation) if you don't already have webpack and CLI installed.


Expand Down Expand Up @@ -221,11 +217,11 @@ Parameter | Explanation | Input type | D

These options allow you to bind [modules](/configuration/module/) as allowed by webpack

Parameter | Explanation | Usage
-------------------- | ---------------------------------- | ----------------
`--module-bind` | Bind an extension to a loader | `--module-bind js=babel-loader`
`--module-bind-post` | Bind an extension to a post loader |
`--module-bind-pre` | Bind an extension to a pre loader |
Parameter | Explanation | Usage
-------------------- | -------------------------------------- | ----------------
`--module-bind` | Bind a file extension to a loader | `--module-bind js=babel-loader`
`--module-bind-post` | Bind a file extension to a post loader |
`--module-bind-pre` | Bind a file extension to a pre loader |


### Watch Options
Expand Down
32 changes: 32 additions & 0 deletions src/content/api/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,38 @@ compiler.hooks.myCustomHook.call(a, b, c);
Again, see the [documentation](https://github.com/webpack/tapable) for `tapable` to learn more about the
different hook classes and how they work.

## Reporting Progress

Plugins can report progress via [`ProgressPlugin`](/plugins/progress-plugin/), which prints progress messages to stderr by default. In order to enable progress reporting, pass a `--progress` argument when running the [webpack CLI](/api/cli/).

It is possible to customize the printed output by passing different arguments to the `reportProgress` function of [`ProgressPlugin`](/plugins/progress-plugin/).

To report progress, a plugin must `tap` into a hook using the `context: true` option:

```js
compiler.hooks.emit.tapAsync({
name: 'MyPlugin',
context: true
}, (context, compiler, callback) => {
const reportProgress = context && context.reportProgress;
if (reportProgress) reportProgress(0.95, 'Starting work');
setTimeout(() => {
if (reportProgress) reportProgress(0.95, 'Done work');
callback();
}, 1000);
});
```

The `reportProgress` function may be called with these arguments:

```js
reportProgress(percentage, ...args);
```

* `percentage`: This argument is unused; instead, [`ProgressPlugin`](/plugins/progress-plugin/) will calculate a percentage based on the current hook.
* `...args`: Any number of strings, which will be passed to the `ProgressPlugin` handler to be reported to the user.

Note that only a subset of compiler and compilation hooks support the `reportProgress` function. See [`ProgressPlugin`](/plugins/progress-plugin/#supported-hooks) for a full list.

## Next Steps

Expand Down
10 changes: 8 additions & 2 deletions src/content/concepts/dependency-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ title: Dependency Graph
sort: 9
contributors:
- TheLarkInn
- EugeneHlushko
related:
- title: HTTP2 Aggresive Splitting Example
url: https://github.com/webpack/webpack/tree/master/examples/http2-aggressive-splitting
- title: webpack & HTTP/2
url: https://medium.com/webpack/webpack-http-2-7083ec3f3ce6
---

Any time one file depends on another, webpack treats this as a _dependency_. This allows webpack to take non-code assets, such as images or web fonts, and also provide them as _dependencies_ for your application.

When webpack processes your application, it starts from a list of modules defined on the command line or in its config file.
Starting from these _entry points_, webpack recursively builds a _dependency graph_ that includes every module your application needs, then packages all of those modules into a small number of _bundles_ - often, just one - to be loaded by the browser.
Starting from these [_entry points_](/concepts/entry-points/), webpack recursively builds a _dependency graph_ that includes every module your application needs, then bundles all of those modules into a small number of _bundles_ - often, just one - to be loaded by the browser.

T> Bundling your application is especially powerful for *HTTP/1.1* clients, as it minimizes the number of times your app has to wait while the browser starts a new request. For *HTTP/2*, you can also use Code Splitting and bundling through webpack for the [best optimization](https://medium.com/webpack/webpack-http-2-7083ec3f3ce6#.7y5d3hz59).
T> Bundling your application is especially powerful for _HTTP/1.1_ clients, as it minimizes the number of times your app has to wait while the browser starts a new request. For _HTTP/2_, you can also use [Code Splitting](/guides/code-splitting/) to achieve best results.
24 changes: 4 additions & 20 deletions src/content/concepts/entry-points.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contributors:
- TheLarkInn
- chrisVillanueva
- byzyk
- sokra
---

As mentioned in [Getting Started](/guides/getting-started/#using-a-configuration), there are multiple ways to define the `entry` property in your webpack configuration. We will show you the ways you **can** configure the `entry` property, in addition to explaining why it may be useful to you.
Expand Down Expand Up @@ -47,7 +48,7 @@ Usage: `entry: {[entryChunkName: string]: string|Array<string>}`
module.exports = {
entry: {
app: './src/app.js',
vendors: './src/vendors.js'
adminApp: './src/adminApp.js'
}
};
```
Expand All @@ -61,26 +62,9 @@ T> **"Scalable webpack configurations"** are ones that can be reused and combine

Below is a list of entry configurations and their real-world use cases:


### Separate App and Vendor Entries

**webpack.config.js**

```javascript
module.exports = {
entry: {
app: './src/app.js',
vendors: './src/vendors.js'
}
};
```

**What does this do?** At face value, this tells webpack to create dependency graphs starting at both `app.js` and `vendors.js`. These graphs are completely separate and independent of each other (there will be a webpack bootstrap in each bundle). This is commonly seen with single page applications which have only one entry point (excluding vendors).

**Why?** This setup allows you to leverage `CommonsChunkPlugin` and extract any vendor references from your app bundle into your vendor bundle, replacing them with `__webpack_require__()` calls. If there is no vendor code in your application bundle, then you can achieve a common pattern in webpack known as [long-term vendor-caching](/guides/caching).

?> Consider removing this scenario in favor of the DllPlugin, which provides a better vendor-splitting.

T> In webpack version < 4 it was common to add vendors as separate entrypoint to compile it as separate file (in combination with the `CommonsChunkPlugin`). This is discouraged in webpack 4. Instead the `optimization.splitChunks` option takes care of separating vendors and app modules and creating a separate file. **Do not** create a entry for vendors or other stuff which is not the starting point of execution.

### Multi Page Application

Expand All @@ -100,6 +84,6 @@ module.exports = {

**Why?** In a multi-page application, the server is going to fetch a new HTML document for you. The page reloads this new document and assets are redownloaded. However, this gives us the unique opportunity to do multiple things:

- Use `CommonsChunkPlugin` to create bundles of shared application code between each page. Multi-page applications that reuse a lot of code/modules between entry points can greatly benefit from these techniques, as the amount of entry points increase.
- Use `optimization.splitChunks` to create bundles of shared application code between each page. Multi-page applications that reuse a lot of code/modules between entry points can greatly benefit from these techniques, as the amount of entry points increase.

T> As a rule of thumb: for each HTML document use exactly one entry point.
3 changes: 2 additions & 1 deletion src/content/concepts/hot-module-replacement.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Hot Module Replacement
sort: 11
contributors:
- kryptokinght
- SpaceK33z
- sokra
- GRardB
Expand All @@ -13,7 +14,7 @@ Hot Module Replacement (HMR) exchanges, adds, or removes [modules](/concepts/mod

- Retain application state which is lost during a full reload.
- Save valuable development time by only updating what's changed.
- Tweak styling faster -- almost comparable to changing styles in the browser's debugger.
- Modifications made to CSS/JS in the source code results in an instant browser update which is almost comparable to changing styles directly in the browser's dev tools.


## How It Works
Expand Down
33 changes: 18 additions & 15 deletions src/content/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ contributors:
- arjunsajeev
- byzyk
- yairhaimo
- EugeneHlushko
- farskid
---

At its core, **webpack** is a _static module bundler_ for modern JavaScript applications. When webpack processes your application, it internally builds a _dependency graph_ which maps every module your project needs and generates one or more _bundles_.
At its core, __webpack__ is a _static module bundler_ for modern JavaScript applications. When webpack processes your application, it internally builds a [dependency graph](/concepts/dependency-graph/) which maps every module your project needs and generates one or more _bundles_.

T> Learn more about JavaScript modules and webpack modules [here](/concepts/modules).

Since version 4.0.0, **webpack does not require a configuration file** to bundle your project, nevertheless it is [incredibly configurable](/configuration) to better fit your needs.
Since version 4.0.0, __webpack does not require a configuration file__ to bundle your project, nevertheless it is [incredibly configurable](/configuration) to better fit your needs.

To get started you only need to understand its **Core Concepts**:
To get started you only need to understand its __Core Concepts__:

- Entry
- Output
- Loaders
- Plugins
- [Entry](#entry)
- [Output](#output)
- [Loaders](#loaders)
- [Plugins](#plugins)
- [Mode](#mode)

This document is intended to give a **high-level** overview of these concepts, while providing links to detailed concept specific use cases.
This document is intended to give a __high-level__ overview of these concepts, while providing links to detailed concept specific use cases.

For a better understanding of the ideas behind module bundlers and how they work under the hood consult these resources:

Expand All @@ -40,9 +43,9 @@ For a better understanding of the ideas behind module bundlers and how they work

## Entry

An **entry point** indicates which module webpack should use to begin building out its internal *dependency graph*. webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly).
An __entry point__ indicates which module webpack should use to begin building out its internal [dependency graph](/concepts/dependency-graph/). webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly).

By default its value is `./src/index.js`, but you can specify a different (or multiple entry points) by configuring the **entry** property in the [webpack configuration](/configuration). For example:
By default its value is `./src/index.js`, but you can specify a different (or multiple entry points) by configuring the __entry__ property in the [webpack configuration](/configuration). For example:

__webpack.config.js__

Expand All @@ -57,7 +60,7 @@ T> Learn more in the [entry points](/concepts/entry-points) section.

## Output

The **output** property tells webpack where to emit the *bundles* it creates and how to name these files. It defaults to `./dist/main.js` for the main output file and to the `./dist` folder for any other generated file.
The __output__ property tells webpack where to emit the *bundles* it creates and how to name these files. It defaults to `./dist/main.js` for the main output file and to the `./dist` folder for any other generated file.

You can configure this part of the process by specifying an `output` field in your configuration:

Expand All @@ -82,11 +85,11 @@ T> The `output` property has [many more configurable features](/configuration/ou

## Loaders

Out of the box, webpack only understands JavaScript files. **Loaders** allow webpack to process other types of files and convert them into valid [modules](/concepts/modules) that can be consumed by your application and added to the dependency graph.
Out of the box, webpack only understands JavaScript and JSON files. __Loaders__ allow webpack to process other types of files and convert them into valid [modules](/concepts/modules) that can be consumed by your application and added to the dependency graph.

W> Note that the ability to `import` any type of module, e.g. `.css` files, is a feature specific to webpack and may not be supported by other bundlers or task runners. We feel this extension of the language is warranted as it allows developers to build a more accurate dependency graph.

At a high level, **loaders** have two properties in your webpack configuration:
At a high level, __loaders__ have two properties in your webpack configuration:

1. The `test` property identifies which file or files should be transformed.
2. The `use` property indicates which loader should be used to do the transforming.
Expand All @@ -110,7 +113,7 @@ module.exports = {

The configuration above has defined a `rules` property for a single module with two required properties: `test` and `use`. This tells webpack's compiler the following:

> "Hey webpack compiler, when you come across a path that resolves to a '.txt' file inside of a `require()`/`import` statement, **use** the `raw-loader` to transform it before you add it to the bundle."
> "Hey webpack compiler, when you come across a path that resolves to a '.txt' file inside of a `require()`/`import` statement, __use__ the `raw-loader` to transform it before you add it to the bundle."

W> It is important to remember that when defining rules in your webpack config, you are defining them under `module.rules` and not `rules`. For your benefit, webpack will warn you if this is done incorrectly.

Expand All @@ -125,7 +128,7 @@ T> Check out the [plugin interface](/api/plugins) and how to use it to extend we

In order to use a plugin, you need to `require()` it and add it to the `plugins` array. Most plugins are customizable through options. Since you can use a plugin multiple times in a config for different purposes, you need to create an instance of it by calling it with the `new` operator.

**webpack.config.js**
__webpack.config.js__

```javascript
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
Expand Down
3 changes: 2 additions & 1 deletion src/content/concepts/loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contributors:
- simon04
- jhnns
- byzyk
- debs-obrien
---

Loaders are transformations that are applied on the source code of a module. They allow you to pre-process files as you `import` or “load” them. Thus, loaders are kind of like “tasks” in other build tools and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript or inline images as data URLs. Loaders even allow you to do things like `import` CSS files directly from your JavaScript modules!
Expand Down Expand Up @@ -121,6 +122,6 @@ functions (loaders). Users now have more flexibility to include fine-grained log

## Resolving Loaders

Loaders follow the standard [module resolution](/concepts/module-resolution/). In most cases it will be loaders from the [module path](/concepts/module-resolution/#module-paths) (think `npm install`, `node_modules`).
Loaders follow the standard [module resolution](/concepts/module-resolution/). In most cases it will be loaded from the [module path](/concepts/module-resolution/#module-paths) (think `npm install`, `node_modules`).

A loader module is expected to export a function and be written in Node.js compatible JavaScript. They are most commonly managed with npm, but you can also have custom loaders as files within your application. By convention, loaders are usually named `xxx-loader` (e.g. `json-loader`). See ["How to Write a Loader?"](/development/how-to-write-a-loader) for more information.
Loading