Skip to content

Commit 59948dc

Browse files
committed
docs(cn): resolve conflicts
1 parent 1af0aea commit 59948dc

File tree

14 files changed

+971
-334
lines changed

14 files changed

+971
-334
lines changed

config/index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ export default defineConfig(({ command, mode, isSsrBuild, isPreview }) => {
6767
})
6868
```
6969

70-
<<<<<<< HEAD
71-
需要注意的是,在 Vite 的 API 中,在开发环境下 `command` 的值为 `serve`(在 CLI 中, `vite dev``vite serve``vite` 的别名),而在生产环境下为 `build``vite build`)。
72-
=======
73-
It is important to note that in Vite's API the `command` value is `serve` during dev (in the cli [`vite`](/guide/cli#vite), `vite dev`, and `vite serve` are aliases), and `build` when building for production ([`vite build`](/guide/cli#vite-build)).
74-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
70+
需要注意的是,在 Vite 的 API 中,在开发环境下 `command` 的值为 `serve`(在 CLI 中, `vite dev``vite serve`[`vite`](/guide/cli#vite) 的别名),而在生产环境下为 `build`[`vite build`](/guide/cli#vite-build))。
7571

7672
`isSsrBuild``isPreview` 是额外的可选标志,用于区分 `build``serve` 命令的类型。一些加载 Vite 配置的工具可能不支持这些标志,而会传递 `undefined`。因此,建议使用 `true``false` 的显式比较。
7773

config/server-options.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,9 @@ export default defineConfig({
152152

153153
设置 `server.hmr.overlay``false` 可以禁用开发服务器错误的屏蔽。
154154

155-
<<<<<<< HEAD
156-
`clientPort` 是一个高级选项,只在客户端的情况下覆盖端口,这允许你为 websocket 提供不同的端口,而并非在客户端代码中查找。如果需要在 dev-server 情况下使用 SSL 代理,这非常有用。
157-
=======
158-
`protocol` sets the WebSocket protocol used for the HMR connection: `ws` (WebSocket) or `wss` (WebSocket Secure).
155+
`protocol` 是用于设置 HMR 连接使用的 WebSocket 协议的选项,可以是 `ws`(WebSocket)或者 `wss`(WebSocket Secure)。
159156

160-
`clientPort` is an advanced option that overrides the port only on the client side, allowing you to serve the websocket on a different port than the client code looks for it on.
161-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
157+
`clientPort` 是一个高级选项,只在客户端的情况下覆盖端口,这允许你为 websocket 提供不同的端口,而并非在客户端代码中查找。如果需要在 dev-server 情况下使用 SSL 代理,这非常有用。
162158

163159
`server.hmr.server` 被定义后,Vite 将会通过所提供的的服务器来处理 HMR 连接。如果不是在中间件模式下,Vite 将尝试通过已有服务器处理 HMR 连接。这在使用自签证书或想通过网络在某端口暴露 Vite 的情况下,非常有用。
164160

config/shared-options.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,14 @@ Vite 有一个“允许的情景”列表,并且会匹配列表中第一个情
163163
- **相关:** [esbuild#preserve-symlinks](https://esbuild.github.io/api/#preserve-symlinks)[webpack#resolve.symlinks
164164
](https://webpack.js.org/configuration/resolve/#resolvesymlinks)
165165

166-
<<<<<<< HEAD
167-
## css.modules {#css-modules}
168-
=======
169166
## html.cspNonce
170167

171-
- **Type:** `string`
172-
- **Related:** [Content Security Policy (CSP)](/guide/features#content-security-policy-csp)
168+
- **类型:** `string`
169+
- **相关:** [内容安全策略(CSP](/guide/features#content-security-policy-csp)
173170

174-
A nonce value placeholder that will be used when generating script / style tags. Setting this value will also generate a meta tag with nonce value.
171+
一个在生成脚本或样式标签时会用到的 nonce 值占位符。设置此值还会生成一个带有 nonce 值的 meta 标签。
175172

176173
## css.modules
177-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
178174

179175
- **类型:**
180176
```ts

config/ssr-options.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
这个选项可以防止列出的依赖项在服务端渲染(SSR)时被外部化,这些依赖项将会在构建过程中被打包。默认情况下,只有软链接的依赖项不会被外部化(这是为了HMR)。如果你希望将软链接的依赖项也外部化,可以将其名称传给 `ssr.external` 选项。
2020

21-
<<<<<<< HEAD
22-
如果这个选项设置为 `true`,那么没有任何依赖项会被外部化。然而,如果你在 `ssr.external` 中明确列出了一些依赖项(使用 `string[]` 类型),那么这些依赖项可以优先被外部化。
23-
=======
24-
If `true`, no dependencies are externalized. However, dependencies explicitly listed in `ssr.external` (using `string[]` type) can take priority and still be externalized. If `ssr.target: 'node'` is set, Node.js built-ins will also be externalized by default.
25-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
21+
如果这个选项设置为 `true`,那么没有任何依赖项会被外部化。然而,如果你在 `ssr.external` 中明确列出了一些依赖项(使用 `string[]` 类型),那么这些依赖项可以优先被外部化。如果设置了 `ssr.target: 'node'`,那么 Node.js 的内置模块也会被默认外部化。
2622

2723
需要注意的是,如果 `ssr.noExternal: true``ssr.external: true` 都被设置了,那么 `ssr.noExternal` 将优先生效,没有任何依赖项会被外部化。
2824

guide/api-hmr.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ import.meta.hot.accept((module) => {
210210
211211
## `hot.off(event, cb)` {#hot-offevent-cb}
212212
213-
<<<<<<< HEAD
214213
从事件监听器中移除回调函数。
215-
=======
216-
Remove callback from the event listeners.
217-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
218214
219215
## `hot.send(event, data)` {#hot-send-event-data}
220216

guide/api-javascript.md

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,15 @@ import { createServer } from 'vite'
1818
1919
const __dirname = fileURLToPath(new URL('.', import.meta.url))
2020
21-
<<<<<<< HEAD
22-
;(async () => {
23-
const server = await createServer({
24-
// 任何合法的用户配置选项,加上 `mode``configFile`
25-
configFile: false,
26-
root: __dirname,
27-
server: {
28-
port: 1337,
29-
},
30-
})
31-
await server.listen()
32-
=======
3321
const server = await createServer({
34-
// any valid user config options, plus `mode` and `configFile`
22+
// 任何合法的用户配置选项,加上 `mode` `configFile`
3523
configFile: false,
3624
root: __dirname,
3725
server: {
3826
port: 1337,
3927
},
4028
})
4129
await server.listen()
42-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
4330
4431
server.printUrls()
4532
server.bindCLIShortcuts({ print: true })
@@ -190,29 +177,25 @@ interface ViteDevServer {
190177
*/
191178
close(): Promise<void>
192179
/**
193-
* Bind CLI shortcuts
180+
* 绑定 CLI 快捷键
194181
*/
195182
bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void
196183
/**
197-
* Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
198-
* are processed. If called from a load or transform plugin hook, the id needs to be
199-
* passed as a parameter to avoid deadlocks. Calling this function after the first
200-
* static imports section of the module graph has been processed will resolve immediately.
201-
* @experimental
184+
* 调用 `await server.waitForRequestsIdle(id)` 会等待所有的静态导入
185+
* 都被处理完。如果这个函数是从一个加载或转换的插件钩子中被调用的,那么你需要
186+
* 把 id 作为参数传入,以避免死锁。在模块图的第一个静态导入部分被处理之后
187+
* 调用这个函数,它将立即返回。
188+
* @实验性
202189
*/
203190
waitForRequestsIdle: (ignoredId?: string) => Promise<void>
204191
}
205192
```
206193

207-
<<<<<<< HEAD
208-
## `build` {#build}
209-
=======
210194
:::info
211-
`waitForRequestsIdle` is meant to be used as a escape hatch to improve DX for features that can't be implemented following the on-demand nature of the Vite dev server. It can be used during startup by tools like Tailwind to delay generating the app CSS classes until the app code has been seen, avoiding flashes of style changes. When this function is used in a load or transform hook, and the default HTTP1 server is used, one of the six http channels will be blocked until the server processes all static imports. Vite's dependency optimizer currently uses this function to avoid full-page reloads on missing dependencies by delaying loading of pre-bundled dependencies until all imported dependencies have been collected from static imported sources. Vite may switch to a different strategy in a future major release, setting `optimizeDeps.crawlUntilStaticImports: false` by default to avoid the performance hit in large applications during cold start.
195+
`waitForRequestsIdle` 的设计初衷是作为一种应急措施,以改善那些无法按照 Vite 开发服务器按需加载特性来实现的功能的开发体验。像 Tailwind 这样的工具可以在启动期间使用它,以便在应用代码被加载之前延迟生成应用的 CSS 类,从而避免样式的闪烁变化。当这个函数在加载或转换钩子中被使用,并且使用的是默认的 HTTP1 服务器时,六个 http 通道中的一个将被阻塞,直到服务器处理完所有的静态导入。Vite 的依赖优化器目前使用这个函数来避免在缺少依赖项时进行全页刷新,它通过延迟加载预打包的依赖项,直到从静态导入的源收集到所有的导入依赖项。在未来的主要版本中,Vite 可能会采取不同的策略,将 `optimizeDeps.crawlUntilStaticImports: false` 设置为默认值,以避免在大型应用程序在冷启动期间出现性能下降。
212196
:::
213197

214-
## `build`
215-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
198+
## `build` {#build}
216199

217200
**类型校验:**
218201

@@ -254,20 +237,9 @@ async function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>
254237

255238
```ts twoslash
256239
import { preview } from 'vite'
257-
<<<<<<< HEAD
258-
;(async () => {
259-
const previewServer = await preview({
260-
// 任何有效的用户配置项,将加上 `mode``configFile`
261-
preview: {
262-
port: 8080,
263-
open: true,
264-
},
265-
})
266-
=======
267-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
268240
269241
const previewServer = await preview({
270-
// any valid user config options, plus `mode` and `configFile`
242+
// 任何合法的用户配置选项,加上 `mode` `configFile`
271243
preview: {
272244
port: 8080,
273245
open: true,

guide/assets.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ document.getElementById('hero-img').src = imgUrl
3232

3333
- 默认情况下,TypeScript 不会将静态资源导入视为有效的模块。要解决这个问题,需要添加 [`vite/client`](./features#client-types)
3434

35-
<<<<<<< HEAD
36-
### 显式 URL 引入 {#explicit-url-imports}
37-
=======
38-
::: tip Inlining SVGs through `url()`
39-
When passing a URL of SVG to a manually constructed `url()` by JS, the variable should be wrapped within double quotes.
35+
::: tip 通过 `url()` 内联 SVG
36+
当在 JS 中手动构造 `url()` 并传入一个 SVG 的 URL 时,应该用双引号将变量包裹起来。
4037

4138
```js twoslash
4239
import 'vite/client'
@@ -47,8 +44,7 @@ document.getElementById('hero-img').style.background = `url("${imgUrl}")`
4744

4845
:::
4946

50-
### Explicit URL Imports
51-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
47+
### 显式 URL 引入 {#explicit-url-imports}
5248

5349
未被包含在内部列表或 `assetsInclude` 中的资源,可以使用 `?url` 后缀显式导入为一个 URL。这十分有用,例如,要导入 [Houdini Paint Worklets](https://houdini.how/usage) 时:
5450

@@ -73,15 +69,10 @@ import shaderString from './shader.glsl?raw'
7369

7470
脚本可以通过 `?worker``?sharedworker` 后缀导入为 web worker。
7571

76-
<<<<<<< HEAD
77-
```js
78-
// 在生产构建中将会分离出 chunk
79-
=======
8072
```js twoslash
8173
import 'vite/client'
8274
// ---cut---
83-
// Separate chunk in the production build
84-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
75+
// 在生产构建中将会分离出 chunk
8576
import Worker from './shader.js?worker'
8677
const worker = new Worker()
8778
```
@@ -94,15 +85,10 @@ import SharedWorker from './shader.js?sharedworker'
9485
const sharedWorker = new SharedWorker()
9586
```
9687

97-
<<<<<<< HEAD
98-
```js
99-
// 内联为 base64 字符串
100-
=======
10188
```js twoslash
10289
import 'vite/client'
10390
// ---cut---
104-
// Inlined as base64 strings
105-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
91+
// 内联为 base64 字符串
10692
import InlineWorker from './shader.js?worker&inline'
10793
```
10894

guide/backend-integration.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -87,65 +87,56 @@
8787
- 清单是一个 `Record<name, chunk>` 结构的对象。
8888
- 对于 入口 或动态入口 chunk,键是相对于项目根目录的资源路径。
8989
- 对于非入口 chunk,键是生成文件的名称并加上前缀 `_`
90-
- Chunk 将信息包含在其静态和动态导入上(两者都是映射到清单中相应 chunk 的键),以及任何与之相关的 CSS 和资源文件。
90+
- Chunk 将信息包含在其静态和动态导入上(两者都是映射到清单中相应 chunk 的键,以及任何与之相关的 CSS 和资源文件。
9191

92-
<<<<<<< HEAD
93-
你可以使用这个文件来渲染链接或者用散列文件名预加载指令(注意:这里的语法只是为了解释,实际使用时请你的服务器模板语言代替):
92+
4. 你可以利用这个文件来渲染带有哈希文件名的链接或预加载指令。
9493

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 提供的。
10597

10698
```html
107-
<!-- if production -->
99+
<!-- 如果是生产环境 -->
108100

109-
<!-- for cssFile of manifest[name].css -->
101+
<!-- 对于 manifest[name].css 中的 cssFile -->
110102
<link rel="stylesheet" href="/{{ cssFile }}" />
111103

112-
<!-- for chunk of importedChunks(manifest, name) -->
113-
<!-- for cssFile of chunk.css -->
104+
<!-- 对于 importedChunks(manifest, name) 中的 chunk -->
105+
<!-- 对于 chunk.css 中的 cssFile -->
114106
<link rel="stylesheet" href="/{{ cssFile }}" />
115107

116108
<script type="module" src="/{{ manifest[name].file }}"></script>
117109

118-
<!-- for chunk of importedChunks(manifest, name) -->
110+
<!-- 对于 importedChunks(manifest, name) 中的 chunk -->
119111
<link rel="modulepreload" src="/{{ chunk.file }}" />
120112
```
121113

122-
Specifically, a backend generating HTML should include the following tags given a manifest
123-
file and an entry point:
114+
具体来说,一个生成 HTML 的后端在给定 manifest 文件和一个入口文件的情况下,
115+
应该包含以下标签:
124116

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 开始递归追踪导入。
132124

133-
Following the above example manifest, for the entry point `main.js` the following tags should be included in production:
125+
按照上面的示例 manifest,对于入口文件 `main.js`,在生产环境中应包含以下标签:
134126

135127
```html
136128
<link rel="stylesheet" href="assets/main.b82dbe22.css" />
137129
<link rel="stylesheet" href="assets/shared.a834bfc3.css" />
138130
<script type="module" src="assets/main.4889e940.js"></script>
139-
<!-- optional -->
131+
<!-- 可选 -->
140132
<link rel="modulepreload" src="assets/shared.83069a53.js" />
141133
```
142134

143-
While the following should be included for the entry point `views/foo.js`:
135+
而对于入口文件 `views/foo.js`,应该包含以下标签:
144136

145137
```html
146138
<link rel="stylesheet" href="assets/shared.a834bfc3.css" />
147139
<script type="module" src="assets/foo.869aea0d.js"></script>
148-
<!-- optional -->
140+
<!-- 可选 -->
149141
<link rel="modulepreload" src="assets/shared.83069a53.js" />
150-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
151142
```

guide/build.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ export default defineConfig({
6969

7070
```js twoslash
7171
window.addEventListener('vite:preloadError', (event) => {
72-
<<<<<<< HEAD
73-
window.reload() // 例如,刷新页面
74-
=======
75-
window.location.reload() // for example, refresh the page
76-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
72+
window.location.reload() // 例如,刷新页面
7773
})
7874
```
7975

@@ -295,4 +291,4 @@ const config: UserConfig = {
295291
}
296292
```
297293

298-
Note that the `filename` passed is a decoded URL, and if the function returns a URL string, it should also be decoded. Vite will handle the encoding automatically when rendering the URLs. If an object with `runtime` is returned, encoding should be handled yourself where needed as the runtime code will be rendered as is.
294+
请注意,传递的 `filename` 是一个已解码的 URL,如果函数返回了一个 URL 字符串,那么它也应该是已解码的。当 Vite 渲染 URL 时会自动处理编码。如果返回的是一个带有 `runtime` 的对象,就需要在必要的地方自行处理编码,因为运行时的代码将会按照原样呈现。

guide/cli.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
### `vite` {#vite}
66

7-
<<<<<<< HEAD
8-
在当前目录下启动 Vite 开发服务器。
9-
=======
10-
Start Vite dev server in the current directory. `vite dev` and `vite serve` are aliases for `vite`.
11-
>>>>>>> 7d52e9105212d56475f86d759d0d77c071cbbdcf
7+
在当前目录下启动 Vite 开发服务器。`vite dev``vite serve``vite` 的别名。
128

139
#### 使用 {#usage}
1410

0 commit comments

Comments
 (0)