You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/concepts/index.md
+20-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,47 +1,50 @@
1
1
---
2
-
title: Core Concepts
2
+
title: Concepts
3
3
sort: 1
4
4
contributors:
5
5
- TheLarkInn
6
6
- jhnns
7
7
- grgur
8
8
- johnstew
9
9
- jimrfenner
10
+
- TheDutchCoder
10
11
---
11
12
12
-
*webpack* is a _module bundler_ for modern JavaScript applications. When webpack processes your application, it 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 only one - to be loaded by the browser.
13
+
At its core, *webpack* is a _module bundler_ for modern JavaScript applications. When webpack processes your application, it recursively builds a _dependency graph_ that includes every module your application needs, then packages all of those modules into one or more _bundles_ to be loaded by the browser.
13
14
14
-
It is [incredibly configurable](/configuration), but to get started you only need to understand **Four Core Concepts**: entry, output, loaders, and plugins.
15
+
It is [incredibly configurable](/configuration), but to get started you only need to understand four **Core Concepts**:
16
+
* Entry
17
+
* Output
18
+
* Loaders
19
+
* Plugins
15
20
16
21
This document is intended to give a **high-level** overview of these concepts, while providing links to detailed concept specific use cases.
17
22
18
23
19
24
## Entry
20
25
21
-
webpack creates a graph of all of your application's dependencies. The starting point of this graph is known as an _entry point_. The _entry point_ tells webpack _where to start_ and follows the graph of dependencies to know _what to bundle_. You can think of your application's _entry point_ as the **contextual root**or **the first file to kick off your app**.
26
+
The **entry** is the starting point for webpack to generate its internal *dependency graph*. This means that webpack starts at your entry point and figures out all the other files and libraries that your entry point is dependent on. It then generates files called *bundles* bases on the **output**configuration (which we'll tackle in the next session).
22
27
23
-
In webpack we define _entry points_ using the `entry` property in our[webpack configuration object](/configuration).
28
+
You can tell webpack which entry point(s) to use by configuring the `entry` property in the[webpack configuration](/configuration).
24
29
25
-
The simplest example is seen below:
30
+
Here's the simplest example of the `entry` configuration:
26
31
27
-
**webpack.config.js**
32
+
__webpack.config.js__
28
33
29
-
```javascript
34
+
```js
30
35
module.exports= {
31
36
entry:'./path/to/my/entry/file.js'
32
37
};
33
38
```
34
39
35
-
There are multiple ways to declare your `entry` property that are specific to your application's needs.
36
-
37
-
[Learn more!](/concepts/entry-points)
40
+
T> There are multiple ways to declare your `entry` property that are specific to your application's needs. You can learn more about this in the [entry points concepts](/concepts/entry-points).
38
41
39
42
40
43
## Output
41
44
42
-
Once you've bundled all of your assets together, you still need to tell webpack **where**to bundle your application. The webpack `output` property tells webpack **how to treat bundled code**.
45
+
The **output** tells webpack where to output the *bundles* it creates. It can also be used to generate filenames dynamically. You can configure the output by specifying an `output` property in the webpack configuration file:
43
46
44
-
**webpack.config.js**
47
+
__webpack.config.js__
45
48
46
49
```javascript
47
50
constpath=require('path');
@@ -59,20 +62,18 @@ In the example above, we use the `output.filename` and the `output.path` propert
59
62
60
63
T> You may see the term **emitted** or **emit** used throughout our documentation and [plugin API](/api/plugins). This is a fancy term for 'produced' or 'discharged'.
61
64
62
-
The `output` property has [many more configurable features](/configuration/output), but let's spend some time understanding some of the most common use cases for the `output` property.
63
-
64
-
[Learn more!](/concepts/output)
65
+
The `output` property has [many more configurable features](/configuration/output) and if you like to know more about the concepts behind the `output` property, you can [read more in the concepts section](/concepts/output).
65
66
66
67
67
68
## Loaders
68
69
69
-
The goal is to have all of the assets in your project be **webpack's** concern and not the browser's (though, to be clear, this doesn't mean that they all have to be bundled together). webpack treats [every file (.css, .html, .scss, .jpg, etc.) as a module](/concepts/modules). However, webpack itself **only understands JavaScript**.
70
+
*Loaders* enable webpack to process more than just JavaScript files (webpack itself only understands JavaScript). They make sure that you can leverage webpack's bundling abilities for files that aren't JavaScript by treating them as [webpack modules](/concepts/modules).
70
71
71
-
**Loaders in webpack _transform these files into modules_ as they are added to your dependency graph.**
72
+
In short: **Loaders in webpack _transform non JavaScript files into modules_ as they are added to your dependency graph.**
72
73
73
74
At a high level, **loaders** have two purposes in your webpack config. They work to:
74
75
75
-
1. Identify which file or files should be transformed by a certain Loader. (`test` property)
76
+
1. Identify which file or files should be transformed by a certain loader (with the `test` property).
76
77
2. Transform those files so that they can be added to your dependency graph (and eventually your bundle). (`use` property)
0 commit comments