@@ -19,7 +19,7 @@ translators:
1919
2020T> 本指南继续沿用 [ ` 管理资源 ` ] ( /guides/asset-management ) 指南中的代码示例。
2121
22- 到目前为止,我们都是在 ` index.html ` 文件中手动引入所有资源,然而随着应用程序增长 ,一旦开始 [ 使用哈希值进行文件命名] ( /guides/caching ) 并输出 [ 多个 bundle] ( /guides/code-splitting ) ,手动管理 ` index.html ` 文件将变得困难。然而,使用一些插件可以让这个过程更容易管理。
22+ 到目前为止,我们都是在 ` index.html ` 文件中手动引入所有资源,然而随着应用程序的不断增长 ,一旦开始 [ 使用哈希值进行文件命名] ( /guides/caching ) 并输出 [ 多个 bundle] ( /guides/code-splitting ) ,手动管理 ` index.html ` 文件将变得困难。然而,使用一些插件可以让这个过程更容易管理。
2323
2424## 预先准备 $#preparation$
2525
@@ -74,7 +74,7 @@ export default function printMe() {
7474 document.body.appendChild(component());
7575```
7676
77- 还要更新 ` dist/index.html ` 文件,来为 webpack 分离入口做好准备 :
77+ 还要更新 ` dist/index.html ` 文件,为 webpack 分离入口文件做好准备 :
7878
7979** dist/index.html**
8080
@@ -94,7 +94,7 @@ export default function printMe() {
9494 </html>
9595```
9696
97- 现在调整配置 。我们将在 entry 添加 ` src/print.js ` 作为新的入口起点(` print ` ),然后修改 output,以便根据入口起点定义的名称,动态地生成 bundle 名称:
97+ 接下来调整配置 。我们将在 entry 添加 ` src/print.js ` 作为新的入口起点(` print ` ),然后修改 output,使得根据入口起点定义的名称,动态生成 bundle 名称:
9898
9999** webpack.config.js**
100100
@@ -132,7 +132,7 @@ webpack 5.4.0 compiled successfully in 1996 ms
132132
133133可以看到,webpack 将会生成 ` print.bundle.js ` 和 ` index.bundle.js ` 文件,这也和我们在 ` index.html ` 文件中指定的文件名称相对应。试试在浏览器中打开 ` index.html ` ,看看点击按钮时会发生什么。
134134
135- 但是,如果更改入口起点的名称,甚至添加一个新的入口,会在构建时重新命名生成的 bundle,而 ` index.html ` 仍然在引用旧的名称。可以使用 [ ` HtmlWebpackPlugin ` ] ( /plugins/html-webpack-plugin ) 来解决这个问题。
135+ 但是,如果更改入口起点的名称,或者添加一个新的入口,那么会在构建时重新命名生成的 bundle,但是 ` index.html ` 仍然在引用旧的名称!我们可以使用 [ ` HtmlWebpackPlugin ` ] ( /plugins/html-webpack-plugin ) 来解决这个问题。
136136
137137## 设置 HtmlWebpackPlugin $#setting-up-htmlwebpackplugin$
138138
@@ -165,7 +165,7 @@ npm install --save-dev html-webpack-plugin
165165 };
166166```
167167
168- 在执行构建之前,你应该了解,虽然在 ` dist/ ` 文件夹我们已经有了 ` index.html ` 这个文件,然而 ` HtmlWebpackPlugin ` 还是会默认生成它自己的 ` index.html ` 文件。也就是说 ,它会用新生成的 ` index.html ` 文件,替换我们的原有文件 。看看执行 ` npm run build ` 后会发生什么:
168+ 在执行构建之前,你应该了解,虽然在 ` dist/ ` 文件夹我们已经有了 ` index.html ` 这个文件,但是 ` HtmlWebpackPlugin ` 还是会默认生成它自己的 ` index.html ` 文件。换言之 ,它会用新生成的 ` index.html ` 文件,替换原有文件 。看看执行 ` npm run build ` 后会发生什么:
169169
170170``` bash
171171...
@@ -181,7 +181,7 @@ cacheable modules 530 KiB
181181webpack 5.4.0 compiled successfully in 2189 ms
182182```
183183
184- 如果在代码编辑器中打开 ` index.html ` ,你会看到 ` HtmlWebpackPlugin ` 创建了一个全新的文件,所有的 bundle 会自动添加到 html 中 。
184+ 如果在代码编辑器中打开 ` index.html ` ,会看到 ` HtmlWebpackPlugin ` 创建了一个全新的文件,所有的 bundle 都自动添加到其中 。
185185
186186如果想要了解 ` HtmlWebpackPlugin ` 插件提供的全部的功能和选项,请阅读 [ ` HtmlWebpackPlugin ` ] ( https://github.com/jantimon/html-webpack-plugin ) 仓库中的源码。
187187
@@ -219,11 +219,11 @@ webpack 5.4.0 compiled successfully in 2189 ms
219219
220220## manifest $#the-manifest$
221221
222- 你可能会很感兴趣,webpack 和 webpack 插件似乎“知道”应该生成哪些文件—— webpack 通过 manifest 追踪所有模块到输出 bundle 之间的映射。如果你想要知道如何以其他方式来控制 webpack [ ` 输出 ` ] ( /configuration/output ) ,了解 manifest 是个好的开始。
222+ 你可能会很感兴趣,webpack 和 webpack 插件似乎“知道”应该生成哪些文件 —— webpack 通过 manifest 追踪所有模块到输出 bundle 之间的映射。如果你想要知道如何以其他方式来控制 webpack [ ` 输出 ` ] ( /configuration/output ) ,了解 manifest 是个好的开始。
223223
224- 通过 [ ` WebpackManifestPlugin ` ] ( https://github.com/shellscape/webpack-manifest-plugin ) 插件,可以将 manifest 数据提取为一个 json 文件以供使用。
224+ [ ` WebpackManifestPlugin ` ] ( https://github.com/shellscape/webpack-manifest-plugin ) 插件可以将 manifest 数据提取为一个 json 文件以供使用。
225225
226- 我们不会在此展示一个如何在项目中使用此插件的完整示例 ,你可以在 [ manifest] ( /concepts/manifest ) 概念页面深入阅读,以及在 [ 缓存] ( /guides/caching ) 指南中,了解它与长效缓存有何关系 。
226+ 我们不会在此展示如何在项目中使用此插件 ,你可以在 [ manifest] ( /concepts/manifest ) 概念页面深入阅读,以及在 [ 缓存] ( /guides/caching ) 指南中了解它与长效缓存有何关系 。
227227
228228## 总结 $#conclusion$
229229
0 commit comments