forked from webpack/webpack.js.org
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
翻译完成 plugins/dll-plugin.md #361
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: DllPlugin | ||
title: DLL插件 (DllPlugin) | ||
contributors: | ||
- aretecode | ||
- sokra | ||
|
@@ -11,66 +11,66 @@ related: | |
url: https://github.com/webpack/webpack/tree/master/examples/explicit-vendor-chunk/README.md | ||
--- | ||
|
||
The `DllPlugin` and `DllReferencePlugin` provide means to split bundles in a way that can drastically improve build time performance. | ||
`DLL插件 (DLLPlugin)` 和 `DLL引用插件 (DLLReferencePlugin)` 用某种方法实现了分割 bundles ,同时还大大提升了编译的速度。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的英文括号(前面不加空格,表示是前面中文的对应英文。 具体见这里 #20 翻译要求 |
||
|
||
|
||
## `DllPlugin` | ||
## `DLL插件 (DllPlugin)` | ||
|
||
This plugin is used in a separate webpack config exclusively to create a dll-only-bundle. It creates a `manifest.json` file, which is used by the [`DllReferencePlugin`](/plugins/dll-plugin#dllreferenceplugin) to map dependencies. | ||
这个插件是在一个额外的独立的 webpack 设置中创建一个只有 dll 的 bundle (dll-only-bundle)。 这个插件会生成一个名为 `manifest.json` 的文件,这个文件是用来让 [`DLL引用插件 (DLLReferencePlugin)`](/plugins/dll-plugin#dllreferenceplugin) 映射到相关的依赖上去的。 | ||
|
||
* `context` (optional): context of requests in the manifest file (defaults to the webpack context.) | ||
* `name`: name of the exposed dll function ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` ) | ||
* `path`: **absolute path** to the manifest json file (output) | ||
* `context` (optional): manifest 文件中请求的上下文(context) (默认值为 webpack 的上下文 (context)) | ||
* `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` ) | ||
* `path`: manifest json 文件的**绝对路径** (输出文件) | ||
|
||
```javascript | ||
new webpack.DllPlugin(options) | ||
``` | ||
|
||
Creates a `manifest.json` which is written to the given `path`. It contains mappings from require and import requests, to module ids. It is used by the `DllReferencePlugin`. | ||
在给定 `地址 (path)` 的地方创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 请求到模块 id 的映射。 `DLL引用插件 (DLLReferencePlugin)` 也会用到这个文件。 | ||
|
||
Combine this plugin with [`output.library`](/configuration/output/#output-library) option to expose (aka, put into the global scope) the dll function. | ||
这个插件与 [`output.library`](/configuration/output/#output-library) 的选项相结合可以暴露出 (也叫做放入全局域) dll 函数。 | ||
|
||
|
||
## `DllReferencePlugin` | ||
## `DLL 引用插件 (DllReferencePlugin)` | ||
|
||
This plugin is used in the primary webpack config, it references the dll-only-bundle(s) to require pre-built dependencies. | ||
这个插件是在 webpack 主配置文件中设置的, 这个插件把只有 dll 的 bundle(们) (dll-only-bundle(s)) 引用到需要的预编译的依赖。 | ||
|
||
* `context`: (**absolute path**) context of requests in the manifest (or content property) | ||
* `manifest` (object): an object containing `content` and `name` | ||
* `content` (optional): the mappings from request to module id (defaults to `manifest.content`) | ||
* `name` (optional): the name where the dll is exposed (defaults to `manifest.name`) (see also [`externals`](/configuration/externals/)) | ||
* `scope` (optional): prefix which is used for accessing the content of the dll | ||
* `sourceType` (optional): how the dll is exposed ([libraryTarget](/configuration/output/#output-librarytarget)) | ||
* `context`: (**绝对路径**) manifest (或者是内容属性)中请求的上下文 | ||
* `manifest` (object): 包含 `content` 和 `name` 的对象 | ||
* `content` (optional): 请求到模块 id 的映射 (默认值为 `manifest.content`) | ||
* `name` (optional): dll 暴露的地方的名称 (默认值为 `manifest.name`) (可参考 [`externals`](/configuration/externals/)) | ||
* `scope` (optional): dll 中内容的前缀 | ||
* `sourceType` (optional): dll 是如何暴露的 ([libraryTarget](/configuration/output/#output-librarytarget)) | ||
|
||
```javascript | ||
new webpack.DllReferencePlugin(options) | ||
``` | ||
|
||
References a dll manifest file to map dependency names to module ids, then requires them as needed using the internal `__webpack_require__` function. | ||
通过引用 dll 的 manifest 文件来把依赖的名称映射到模块的 id 上,之后再在需要的时候通过内置的 `__webpack_require__` 函数来 `require` 他们 | ||
|
||
W> Keep the `name` consistent with [`output.library`](/configuration/output/#output-library). | ||
W> 与 [`output.library`](/configuration/output/#output-library) 保持 `name` 的一致性。 | ||
|
||
|
||
### Modes | ||
### 模式 (Modes) | ||
|
||
This plugin can be used in two different modes, _scoped_ and _mapped_. | ||
这个插件支持两种模式,分别是 _作用域 (scoped)_ 和 _映射 (mapped)_ 。 | ||
|
||
#### Scoped Mode | ||
#### 作用域模式 (Scoped Mode) | ||
|
||
The content of the dll is accessible under a module prefix. i.e. with `scope = "xyz"` a file `abc` in the dll can be access via `require("xyz/abc")`. | ||
dll 中的内容可以在模块前缀下才能被引用,举例来说,令`scope = "xyz" `的话,这个 dll 中的名为 `abc` 的文件可以通过 `require("xyz/abc")` 来获取 | ||
|
||
T> [See an example use of scope](https://github.com/webpack/webpack/tree/master/examples/dll-user) | ||
T> [作用域的用例](https://github.com/webpack/webpack/tree/master/examples/dll-user) | ||
|
||
#### Mapped Mode | ||
#### 映射模式 (Mapped Mode) | ||
|
||
The content of the dll is mapped to the current directory. If a required file matches a file in the dll (after resolving), then the file from the dll is used instead. | ||
dll 中的内容被映射到了当前目录下。如果一个被 `require` 的文件符合 dll 中的某个文件(解析之后),那么这个dll中的这个文件就会被使用。 | ||
|
||
Because this happens after resolving every file in the dll bundle, the same paths must be available for the consumer of the dll bundle. i.e. if the dll contains `lodash` and the file `abc`, `require("lodash")` and `require("./abc")` will be used from the dll, rather than building them into the main bundle. | ||
由于这是在解析了 dll 中每个文件之后才发生的,相同的路径必须能够确保这个 dll bundle 的使用者(不一定是人,可指某些代码)有权限访问。 举例来说, 假如一个 dll bundle 中含有 `loadash`库 以及 文件`abc`, 那么 `require("lodash")` 和 `require("./abc")` 都不会被编译进主要的 bundle文件,而是会被 dll 所使用。 | ||
|
||
|
||
## Usage | ||
## 使用 (Usage) | ||
|
||
W> `DllReferencePlugin` and `DllPlugin` are used in _separate_ webpack configs. | ||
W> `DLL引用插件 (DllReferencePlugin)` 和 `DLL插件 (DllPlugin)` 都是在 _另外_ 的 webpack 设置中使用的。 | ||
|
||
**webpack.vendor.config.js** | ||
|
||
|
@@ -95,13 +95,13 @@ new webpack.DllReferencePlugin({ | |
``` | ||
|
||
|
||
## Examples | ||
## 例子 (Examples) | ||
|
||
[Vendor](https://github.com/webpack/webpack/tree/master/examples/dll) and [User](https://github.com/webpack/webpack/tree/master/examples/dll-user) | ||
|
||
_Two separate example folders. Demonstrates scope and context._ | ||
_两个单独的用例,用来分别演示作用域 (scope) 和上下文 (context)_ | ||
|
||
T> Multiple `DllPlugins` and multiple `DllReferencePlugins`. | ||
T> 多个 `DLL插件 (DllPlugins)` 和 `DLL引用插件 (DllReferencePlugins)`. | ||
|
||
|
||
## References | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 107行翻译为引用参考 |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里就用 DllPlugin 吧