Skip to content

Commit 02cdcfa

Browse files
jungorJunjie LiQC-L
authored
docs(cn): translate src/content/configuration/entry-context.md (#757)
* docs(cn): translate src/content/configuration/entry-context.md * docs(cn): fix src/content/configuration/entry-context.md format * Update entry-context.md Co-authored-by: Junjie Li <[email protected]> Co-authored-by: QiChang Li <[email protected]>
1 parent fcc16ad commit 02cdcfa

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/content/configuration/entry-context.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Entry and Context
2+
title: 入口和上下文(entry and context)
33
sort: 4
44
contributors:
55
- sokra
@@ -11,14 +11,14 @@ contributors:
1111
- smelukov
1212
---
1313

14-
The entry object is where webpack looks to start building the bundle. The context is an absolute string to the directory that contains the entry files.
14+
入口对象是用于 webpack 查找开始构建 bundle 的地方。上下文是入口文件所处的目录的绝对路径的字符串。
1515

1616

1717
## `context`
1818

1919
`string`
2020

21-
The base directory, an __absolute path__, for resolving entry points and loaders from configuration.
21+
基础目录,__绝对路径__,用于从配置中解析入口点(entry point)和 加载器(loader)。
2222

2323
``` js
2424
const path = require('path');
@@ -29,7 +29,7 @@ module.exports = {
2929
};
3030
```
3131

32-
By default the current directory is used, but it's recommended to pass a value in your configuration. This makes your configuration independent from CWD (current working directory).
32+
默认使用当前目录,但是推荐在配置中传入一个值。这使得你的配置独立于 CWD(current working directory, 当前工作目录)。
3333

3434
---
3535

@@ -38,11 +38,11 @@ By default the current directory is used, but it's recommended to pass a value i
3838

3939
`string` `[string]` `object = { <key> string | [string] | object = { import string | [string], dependOn string | [string], filename string }}` `(function() => string | [string] | object = { <key> string | [string] } | object = { import string | [string], dependOn string | [string], filename string })`
4040

41-
The point or points where to start the application bundling process. If an array is passed then all items will be processed.
41+
开始应用程序打包过程的一个或多个起点。如果传入数组,则会处理所有条目。
4242

43-
A dynamically loaded module is __not__ an entry point.
43+
动态加载的模块 __不是__ 入口起点。
4444

45-
Simple rule: one entry point per HTML page. SPA: one entry point, MPA: multiple entry points.
45+
简单规则:每个 HTML 页面都有一个入口起点。单页应用(SPA):一个入口起点,多页应用(MPA):多个入口起点。
4646

4747
```js
4848
module.exports = {
@@ -58,11 +58,11 @@ module.exports = {
5858

5959
### Naming
6060

61-
If a string or array of strings is passed, the chunk is named `main`. If an object is passed, each key is the name of a chunk, and the value describes the entry point for the chunk.
61+
如果传入一个字符串或字符串数组,chunk 会被命名为 `main`。如果传入一个对象,则每个属性的键(key)会是 chunk 的名称,该属性的值描述了 chunk 的入口点。
6262

6363
### Entry descriptor
6464

65-
If an object is passed the value might be a string, array of strings or a descriptor:
65+
如果传入一个对象,对象的属性的值可以是一个字符串、字符串数组或者一个描述符(descriptor):
6666

6767
```js
6868
module.exports = {
@@ -84,12 +84,12 @@ module.exports = {
8484
};
8585
```
8686

87-
Descriptor syntax might be used to pass additional options to an entry point.
87+
描述符语法可以用来传入额外的选项给入口。
8888

8989

9090
### Output filename
9191

92-
By default, the output filename for the entry chunk is extracted from [`output.filename`](/configuration/output/#outputfilename) but you can specify a custom output filename for a specific entry:
92+
默认情况下,入口 chunk 的输出文件名是从 [`output.filename`](/configuration/output/#outputfilename) 中提取出来的,但你可以为特定的入口指定一个自定义的输出文件名。
9393

9494
```js
9595
module.exports = {
@@ -102,12 +102,12 @@ module.exports = {
102102
};
103103
```
104104

105-
Descriptor syntax was used here to pass `filename`-option to the specific entry points.
105+
描述符语法在这里被用来将 `filename`—选项传递给指定的入口点。
106106

107107

108108
### Dependencies
109109

110-
By default, every entry chunk stores all the modules that it uses. With `dependOn`-option you can share the modules from one entry chunk to another:
110+
默认情况下,每个入口 chunk 保存了全部其用的模块(modules)。使用 `dependOn`—选项你可以与另一个入口 chunk 共享模块:
111111

112112
```js
113113
module.exports = {
@@ -119,9 +119,9 @@ module.exports = {
119119
};
120120
```
121121

122-
The `app` chunk will not contain the modules that `react-vendors` has.
122+
`app` 这个 chunk 就不会包含 `react-vendors` 拥有的模块了.
123123

124-
Also you can specify multiple files per entry using array:
124+
你也可以使用数组为一个入口指定多个文件:
125125

126126
```js
127127
module.exports = {
@@ -135,9 +135,9 @@ module.exports = {
135135

136136
### Dynamic entry
137137

138-
If a function is passed then it will be invoked on every [make](/api/compiler-hooks/#make) event.
138+
如果传入一个函数,那么它将会在每次 [make](/api/compiler-hooks/#make) 事件中被调用。
139139

140-
> Note that the make event triggers when webpack starts and for every invalidation when [watching for file changes](/configuration/watch/).
140+
> 要注意的是,make 事件在 webpack 启动和每当 [监听文件变化](/configuration/watch/) 时都会触发。
141141
142142
```js
143143
module.exports = {
@@ -146,7 +146,7 @@ module.exports = {
146146
};
147147
```
148148

149-
or
149+
或者
150150

151151
```js
152152
module.exports = {
@@ -155,16 +155,16 @@ module.exports = {
155155
};
156156
```
157157

158-
For example: you can use dynamic entries to get the actual entries from an external source (remote server, file system content or database):
158+
例如,你可以使用动态入口来从外部来源(远程服务器,文件系统内容或者数据库)获取真正的入口:
159159

160160
__webpack.config.js__
161161

162162
``` js
163163
module.exports = {
164164
entry() {
165-
return fetchPathsFromSomeExternalSource(); // returns a promise that will be resolved with something like ['src/main-layout.js', 'src/admin-layout.js']
165+
return fetchPathsFromSomeExternalSource(); // 返回一个会被用像 ['src/main-layout.js', 'src/admin-layout.js'] 的东西 resolve 的 promise
166166
}
167167
};
168168
```
169169

170-
When combining with the [`output.library`](/configuration/output/#outputlibrary) option: If an array is passed only the last item is exported.
170+
当和 [`output.library`](/configuration/output/#outputlibrary) 选项结合:如果传入的是一个数组,只有数组的最后一个条目会被导出。

0 commit comments

Comments
 (0)