|
87 | 87 | - 清单是一个 `Record<name, chunk>` 结构的对象。 |
88 | 88 | - 对于 入口 或动态入口 chunk,键是相对于项目根目录的资源路径。 |
89 | 89 | - 对于非入口 chunk,键是生成文件的名称并加上前缀 `_`。 |
90 | | - - Chunk 将信息包含在其静态和动态导入上(两者都是映射到清单中相应 chunk 的键),以及任何与之相关的 CSS 和资源文件。 |
| 90 | + - Chunk 将信息包含在其静态和动态导入上(两者都是映射到清单中相应 chunk 的键),以及任何与之相关的 CSS 和资源文件。 |
91 | 91 |
|
92 | | -<<<<<<< HEAD |
93 | | - 你可以使用这个文件来渲染链接或者用散列文件名预加载指令(注意:这里的语法只是为了解释,实际使用时请你的服务器模板语言代替): |
| 92 | +4. 你可以利用这个文件来渲染带有哈希文件名的链接或预加载指令。 |
94 | 93 |
|
95 | | - ```html |
96 | | - <!-- 如果是在生产环境中 --> |
97 | | - <link rel="stylesheet" href="/assets/{{ manifest['main.js'].css }}" /> |
98 | | - <script type="module" src="/assets/{{ manifest['main.js'].file }}"></script> |
99 | | -======= |
100 | | -4. You can use this file to render links or preload directives with hashed filenames. |
101 | | - |
102 | | - Here is an example HTML template to render the proper links. The syntax here is for |
103 | | - explanation only, substitute with your server templating language. The `importedChunks` |
104 | | - function is for illustration and isn't provided by Vite. |
| 94 | + 这是一个用来渲染正确链接的 HTML 模板示例。这里的语法仅用于解释, |
| 95 | + 你需要用你的服务器模板语言来替换。`importedChunks` 函数只是 |
| 96 | + 用来说明,并不是 Vite 提供的。 |
105 | 97 |
|
106 | 98 | ```html |
107 | | - <!-- if production --> |
| 99 | + <!-- 如果是生产环境 --> |
108 | 100 |
|
109 | | - <!-- for cssFile of manifest[name].css --> |
| 101 | + <!-- 对于 manifest[name].css 中的 cssFile --> |
110 | 102 | <link rel="stylesheet" href="/{{ cssFile }}" /> |
111 | 103 |
|
112 | | - <!-- for chunk of importedChunks(manifest, name) --> |
113 | | - <!-- for cssFile of chunk.css --> |
| 104 | + <!-- 对于 importedChunks(manifest, name) 中的 chunk --> |
| 105 | + <!-- 对于 chunk.css 中的 cssFile --> |
114 | 106 | <link rel="stylesheet" href="/{{ cssFile }}" /> |
115 | 107 |
|
116 | 108 | <script type="module" src="/{{ manifest[name].file }}"></script> |
117 | 109 |
|
118 | | - <!-- for chunk of importedChunks(manifest, name) --> |
| 110 | + <!-- 对于 importedChunks(manifest, name) 中的 chunk --> |
119 | 111 | <link rel="modulepreload" src="/{{ chunk.file }}" /> |
120 | 112 | ``` |
121 | 113 |
|
122 | | - Specifically, a backend generating HTML should include the following tags given a manifest |
123 | | - file and an entry point: |
| 114 | + 具体来说,一个生成 HTML 的后端在给定 manifest 文件和一个入口文件的情况下, |
| 115 | + 应该包含以下标签: |
124 | 116 |
|
125 | | - - A `<link rel="stylesheet">` tag for each file in the entry point chunk's `css` list |
126 | | - - Recursively follow all chunks in the entry point's `imports` list and include a |
127 | | - `<link rel="stylesheet">` tag for each css file of each imported chunk. |
128 | | - - A tag for the `file` key of the entry point chunk (`<script type="moudle">` for Javascript, |
129 | | - or `<link rel="stylesheet">` for css) |
130 | | - - Optionally, `<link rel="modulepreload">` tag for the `file` of each imported Javascript |
131 | | - chunk, again recursively following the imports starting from the entry point chunk. |
| 117 | + - 对于入口文件 chunk 的 `css` 列表中的每个文件,都应包含一个 `<link rel="stylesheet">` 标签。 |
| 118 | + - 递归追踪入口文件的 `imports` 列表中的所有 chunk,并为每个导入的 chunk 的每个 css 文件 |
| 119 | + 包含一个 `<link rel="stylesheet">` 标签。 |
| 120 | + - 对于入口文件 chunk 的 `file` 键的标签(对于 Javascript 是 |
| 121 | + `<script type="moudle">`,对于 css 是 `<link rel="stylesheet">`) |
| 122 | + - 可选项,对于每个导入的 Javascript chunk 的 `file` 键的 `<link rel="modulepreload">` 标签, |
| 123 | + 同样从入口文件 chunk 开始递归追踪导入。 |
132 | 124 |
|
133 | | - Following the above example manifest, for the entry point `main.js` the following tags should be included in production: |
| 125 | + 按照上面的示例 manifest,对于入口文件 `main.js`,在生产环境中应包含以下标签: |
134 | 126 |
|
135 | 127 | ```html |
136 | 128 | <link rel="stylesheet" href="assets/main.b82dbe22.css" /> |
137 | 129 | <link rel="stylesheet" href="assets/shared.a834bfc3.css" /> |
138 | 130 | <script type="module" src="assets/main.4889e940.js"></script> |
139 | | - <!-- optional --> |
| 131 | + <!-- 可选 --> |
140 | 132 | <link rel="modulepreload" src="assets/shared.83069a53.js" /> |
141 | 133 | ``` |
142 | 134 |
|
143 | | - While the following should be included for the entry point `views/foo.js`: |
| 135 | + 而对于入口文件 `views/foo.js`,应该包含以下标签: |
144 | 136 |
|
145 | 137 | ```html |
146 | 138 | <link rel="stylesheet" href="assets/shared.a834bfc3.css" /> |
147 | 139 | <script type="module" src="assets/foo.869aea0d.js"></script> |
148 | | - <!-- optional --> |
| 140 | + <!-- 可选 --> |
149 | 141 | <link rel="modulepreload" src="assets/shared.83069a53.js" /> |
150 | | ->>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf |
151 | 142 | ``` |
0 commit comments