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: content/concepts/index.md
+32-30Lines changed: 32 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,17 @@ contributors:
4
4
- TheLarkInn
5
5
---
6
6
7
-
*webpack*is a _module bundler_ for modern JavaScript applications. It is [incredibly configurable](./api/configuration), however, there are **4 Core Concepts** we feel you should understand before you get started!
As part of your webpack learning journey, we wrote this document aimed to give you a **high-level** overview of these concepts, while still providing links to concept specific use-cases.
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 dependendencies to know _what to bundle_. You can think of your applications _entry point_ as the **contextual root**or**the first file to kick off your app**.
There are multiple ways to declare your `entry`property that are specific to your applications needs.
29
+
这里有多种方式声明应用程序所需的那些特定 `entry`属性。
30
30
31
-
[**Learn more!**](./entry-points)
31
+
[**了解更多!**](./entry-points)
32
32
33
-
## Output
33
+
## 出口(Output)
34
34
35
-
Once you've bundled all of your assets together, we still need to tell webpack **where**to bundle our application. The webpack `output`property describes to webpack **how to treat bundled code**.
In the example above, through the `output.filename` and `output.path` properties we are describing to webpack the name of our bundle, and where we want it to be emitted to.
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".
52
54
53
-
The`output`property has [many more configurable features](../api/configuration), but lets spend some time understanding some of the most common use cases for the `output`property.
The goal is to have all of your assets in your project to be **webpack's**concern and not the browser. (This doesn't mean that they all have to be bundled together). webpack treats [every file (.css, .html, .scss, .jpg, etc.) as a module](./modules). However, webpack **only understands JavaScript**.
At a high level, they have two purposes in your webpack config.
66
+
webpack 配置在更高层面有两个目标。
65
67
66
-
1.Identify what files should be transformed by a certain loader. (`test` property)
67
-
2.Transform that file so that it can be added to your dependency graph (and eventually your bundle). (`loader`property)
68
+
1.识别出(identify)应该被特定的加载器转换(transform)的文件
69
+
2.转换能够被添加到依赖图表的文件(并且最终打包)(`loader`属性)
68
70
69
71
**webpack.config.js**
70
72
@@ -83,21 +85,21 @@ const config = {
83
85
};
84
86
```
85
87
86
-
In the configuration above we have defined our loader with its two required properties: `test`, and`loader`. It tells webpack's compiler the following:
> "Hey webpack compiler, when you come across a path that resolves to a '.js' or '.jsx' file inside of a require() statement, use the babel-loader to transform it before you bundle it together".
There are more specific properties to define on loaders that we haven't yet covered.
94
+
我们还有尚未提到的 loader,可以设定更多特定属性。
93
95
94
-
[**Learn more!**]('./loaders')
96
+
[**了解更多!**](./loaders)
95
97
96
-
## Plugins
98
+
## 插件(Plugins)
97
99
98
-
Since Loaders only execute transforms on a per-file basis, Plugins are most commonly used (but not limited to) performing actions and custom functionality on "compilations" or "chunks" of your bundled modules [(and so much more)](./plugins). The webpack Plugin system is [extremely powerful and customizable](../api/plugins).
In order to use a plugin, you just need to `require()`it and add it to the `plugins`array. Since most plugins are customizable via options, you need to create an instance of it by calling it with `new`.
There are many plugins that webpack provides out of the box! Check out our [list of plugins](https://webpack.github.io/docs/list-of-plugins.html) for more information.
0 commit comments