From e09bc4c9ff4b44ca3a84e7fb6a89cb37d089dc18 Mon Sep 17 00:00:00 2001 From: Junchao Wang Date: Thu, 10 Aug 2017 15:22:18 +1000 Subject: [PATCH 1/5] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90=20plug?= =?UTF-8?q?ins/dll-plugin.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/plugins/dll-plugin.md | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/content/plugins/dll-plugin.md b/content/plugins/dll-plugin.md index 1ee05e2c15ba..26e3ea371986 100644 --- a/content/plugins/dll-plugin.md +++ b/content/plugins/dll-plugin.md @@ -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 ,同时还大大提升了编译的速度。 -## `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 From 102d8258ed9452ee02b2f078664faabdf96ab2eb Mon Sep 17 00:00:00 2001 From: Junchao Wang Date: Thu, 10 Aug 2017 19:56:14 +1000 Subject: [PATCH 2/5] Update dll-plugin.md --- content/plugins/dll-plugin.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/content/plugins/dll-plugin.md b/content/plugins/dll-plugin.md index 26e3ea371986..c8dc90b74b8b 100644 --- a/content/plugins/dll-plugin.md +++ b/content/plugins/dll-plugin.md @@ -1,5 +1,5 @@ --- -title: DLL插件 (DllPlugin) +title: DllPlugin contributors: - aretecode - sokra @@ -11,14 +11,14 @@ related: url: https://github.com/webpack/webpack/tree/master/examples/explicit-vendor-chunk/README.md --- -`DLL插件 (DLLPlugin)` 和 `DLL引用插件 (DLLReferencePlugin)` 用某种方法实现了分割 bundles ,同时还大大提升了编译的速度。 +`DLLPlugin` 和 `DLLReferencePlugin` 用某种方法实现了分割 bundles,同时还大大提升了编译的速度。 -## `DLL插件 (DllPlugin)` +## `DllPlugin` -这个插件是在一个额外的独立的 webpack 设置中创建一个只有 dll 的 bundle (dll-only-bundle)。 这个插件会生成一个名为 `manifest.json` 的文件,这个文件是用来让 [`DLL引用插件 (DLLReferencePlugin)`](/plugins/dll-plugin#dllreferenceplugin) 映射到相关的依赖上去的。 +这个插件是在一个额外的独立的 webpack 设置中创建一个只有 dll 的 bundle(dll-only-bundle)。 这个插件会生成一个名为 `manifest.json` 的文件,这个文件是用来让 [`DLLReferencePlugin`](/plugins/dll-plugin#dllreferenceplugin) 映射到相关的依赖上去的。 -* `context` (optional): manifest 文件中请求的上下文(context) (默认值为 webpack 的上下文 (context)) +* `context` (optional): manifest 文件中请求的上下文(context)(默认值为 webpack 的上下文(context)) * `name`: 暴露出的 DLL 的函数名 ([TemplatePaths](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js): `[hash]` & `[name]` ) * `path`: manifest json 文件的**绝对路径** (输出文件) @@ -26,14 +26,14 @@ related: new webpack.DllPlugin(options) ``` -在给定 `地址 (path)` 的地方创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 请求到模块 id 的映射。 `DLL引用插件 (DLLReferencePlugin)` 也会用到这个文件。 +在给定 `地址(path)` 的地方创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 请求到模块 id 的映射。 `DLLReferencePlugin` 也会用到这个文件。 这个插件与 [`output.library`](/configuration/output/#output-library) 的选项相结合可以暴露出 (也叫做放入全局域) dll 函数。 -## `DLL 引用插件 (DllReferencePlugin)` +## `DllReferencePlugin` -这个插件是在 webpack 主配置文件中设置的, 这个插件把只有 dll 的 bundle(们) (dll-only-bundle(s)) 引用到需要的预编译的依赖。 +这个插件是在 webpack 主配置文件中设置的, 这个插件把只有 dll 的 bundle(们)(dll-only-bundle(s)) 引用到需要的预编译的依赖。 * `context`: (**绝对路径**) manifest (或者是内容属性)中请求的上下文 * `manifest` (object): 包含 `content` 和 `name` 的对象 @@ -51,26 +51,26 @@ new webpack.DllReferencePlugin(options) W> 与 [`output.library`](/configuration/output/#output-library) 保持 `name` 的一致性。 -### 模式 (Modes) +### 模式(Modes) -这个插件支持两种模式,分别是 _作用域 (scoped)_ 和 _映射 (mapped)_ 。 +这个插件支持两种模式,分别是 _作用域(scoped)_ 和 _映射(mapped)_ 。 -#### 作用域模式 (Scoped Mode) +#### 作用域模式(Scoped Mode) dll 中的内容可以在模块前缀下才能被引用,举例来说,令`scope = "xyz" `的话,这个 dll 中的名为 `abc` 的文件可以通过 `require("xyz/abc")` 来获取 T> [作用域的用例](https://github.com/webpack/webpack/tree/master/examples/dll-user) -#### 映射模式 (Mapped Mode) +#### 映射模式(Mapped Mode) dll 中的内容被映射到了当前目录下。如果一个被 `require` 的文件符合 dll 中的某个文件(解析之后),那么这个dll中的这个文件就会被使用。 由于这是在解析了 dll 中每个文件之后才发生的,相同的路径必须能够确保这个 dll bundle 的使用者(不一定是人,可指某些代码)有权限访问。 举例来说, 假如一个 dll bundle 中含有 `loadash`库 以及 文件`abc`, 那么 `require("lodash")` 和 `require("./abc")` 都不会被编译进主要的 bundle文件,而是会被 dll 所使用。 -## 使用 (Usage) +## 使用(Usage) -W> `DLL引用插件 (DllReferencePlugin)` 和 `DLL插件 (DllPlugin)` 都是在 _另外_ 的 webpack 设置中使用的。 +W> `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) _两个单独的用例,用来分别演示作用域 (scope) 和上下文 (context)_ -T> 多个 `DLL插件 (DllPlugins)` 和 `DLL引用插件 (DllReferencePlugins)`. +T> 多个 `DllPlugins` 和 `DllReferencePlugins`. ## References From cf628dddf3cd5fa3b731cd79b0b4eb99014904a0 Mon Sep 17 00:00:00 2001 From: Junchao Wang Date: Thu, 10 Aug 2017 19:56:36 +1000 Subject: [PATCH 3/5] Update dll-plugin.md --- content/plugins/dll-plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/plugins/dll-plugin.md b/content/plugins/dll-plugin.md index c8dc90b74b8b..7a16a89157b1 100644 --- a/content/plugins/dll-plugin.md +++ b/content/plugins/dll-plugin.md @@ -99,7 +99,7 @@ new webpack.DllReferencePlugin({ [Vendor](https://github.com/webpack/webpack/tree/master/examples/dll) and [User](https://github.com/webpack/webpack/tree/master/examples/dll-user) -_两个单独的用例,用来分别演示作用域 (scope) 和上下文 (context)_ +_两个单独的用例,用来分别演示作用域(scope) 和上下文(context)_ T> 多个 `DllPlugins` 和 `DllReferencePlugins`. From fc926f7b70e043b60ff92d0670e124923b2022e7 Mon Sep 17 00:00:00 2001 From: Junchao Wang Date: Sun, 13 Aug 2017 18:04:46 +1000 Subject: [PATCH 4/5] Update dll-plugin.md --- content/plugins/dll-plugin.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/content/plugins/dll-plugin.md b/content/plugins/dll-plugin.md index 7a16a89157b1..0c02c99cae27 100644 --- a/content/plugins/dll-plugin.md +++ b/content/plugins/dll-plugin.md @@ -11,7 +11,7 @@ related: url: https://github.com/webpack/webpack/tree/master/examples/explicit-vendor-chunk/README.md --- -`DLLPlugin` 和 `DLLReferencePlugin` 用某种方法实现了分割 bundles,同时还大大提升了编译的速度。 +`DLLPlugin` 和 `DLLReferencePlugin` 用某种方法实现了拆分 bundles,同时还大大提升了构建的速度。 ## `DllPlugin` @@ -26,7 +26,7 @@ related: new webpack.DllPlugin(options) ``` -在给定 `地址(path)` 的地方创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 请求到模块 id 的映射。 `DLLReferencePlugin` 也会用到这个文件。 +在给定 `地址(path)` 的路径下创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 的request到模块 id 的映射。 `DLLReferencePlugin` 也会用到这个文件。 这个插件与 [`output.library`](/configuration/output/#output-library) 的选项相结合可以暴露出 (也叫做放入全局域) dll 函数。 @@ -48,7 +48,7 @@ new webpack.DllReferencePlugin(options) 通过引用 dll 的 manifest 文件来把依赖的名称映射到模块的 id 上,之后再在需要的时候通过内置的 `__webpack_require__` 函数来 `require` 他们 -W> 与 [`output.library`](/configuration/output/#output-library) 保持 `name` 的一致性。 +W> 与 [`output.library`](/configuration/output/#output-library) 保持 `name` 的一致性。 ### 模式(Modes) @@ -68,7 +68,7 @@ dll 中的内容被映射到了当前目录下。如果一个被 `require` 的 由于这是在解析了 dll 中每个文件之后才发生的,相同的路径必须能够确保这个 dll bundle 的使用者(不一定是人,可指某些代码)有权限访问。 举例来说, 假如一个 dll bundle 中含有 `loadash`库 以及 文件`abc`, 那么 `require("lodash")` 和 `require("./abc")` 都不会被编译进主要的 bundle文件,而是会被 dll 所使用。 -## 使用(Usage) +## 用法(Usage) W> `DllReferencePlugin` 和 `DLL插件DllPlugin` 都是在 _另外_ 的 webpack 设置中使用的。 @@ -95,16 +95,16 @@ 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) -_两个单独的用例,用来分别演示作用域(scope) 和上下文(context)_ +_两个单独的用例,用来分别演示作用域(scope) 和上下文(context)_。 T> 多个 `DllPlugins` 和 `DllReferencePlugins`. -## References +## 引用参考(References) ### Source From 068fe7b4c764e7eddfcdd26a0e029b758abbd5fa Mon Sep 17 00:00:00 2001 From: lizhihua <275091674@qq.com> Date: Tue, 15 Aug 2017 14:37:45 +0800 Subject: [PATCH 5/5] Update dll-plugin.md --- content/plugins/dll-plugin.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/plugins/dll-plugin.md b/content/plugins/dll-plugin.md index 0c02c99cae27..2a29757b80c2 100644 --- a/content/plugins/dll-plugin.md +++ b/content/plugins/dll-plugin.md @@ -26,7 +26,7 @@ related: new webpack.DllPlugin(options) ``` -在给定 `地址(path)` 的路径下创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 的request到模块 id 的映射。 `DLLReferencePlugin` 也会用到这个文件。 +在给定的 `path` 路径下创建一个名为 `manifest.json` 的文件。 这个文件包含了从 `require` 和 `import` 的request到模块 id 的映射。 `DLLReferencePlugin` 也会用到这个文件。 这个插件与 [`output.library`](/configuration/output/#output-library) 的选项相结合可以暴露出 (也叫做放入全局域) dll 函数。 @@ -53,7 +53,7 @@ W> 与 [`output.library`](/configuration/output/#output-library) 保持 `name` ### 模式(Modes) -这个插件支持两种模式,分别是 _作用域(scoped)_ 和 _映射(mapped)_ 。 +这个插件支持两种模式,分别是_作用域(scoped)_和_映射(mapped)_。 #### 作用域模式(Scoped Mode) @@ -70,7 +70,7 @@ dll 中的内容被映射到了当前目录下。如果一个被 `require` 的 ## 用法(Usage) -W> `DllReferencePlugin` 和 `DLL插件DllPlugin` 都是在 _另外_ 的 webpack 设置中使用的。 +W> `DllReferencePlugin` 和 `DLL插件DllPlugin` 都是在_另外_的 webpack 设置中使用的。 **webpack.vendor.config.js** @@ -99,7 +99,7 @@ new webpack.DllReferencePlugin({ [Vendor](https://github.com/webpack/webpack/tree/master/examples/dll) and [User](https://github.com/webpack/webpack/tree/master/examples/dll-user) -_两个单独的用例,用来分别演示作用域(scope) 和上下文(context)_。 +_两个单独的用例,用来分别演示作用域(scope)和上下文(context)。_ T> 多个 `DllPlugins` 和 `DllReferencePlugins`.