Skip to content

Commit 9d40428

Browse files
committed
docs(cn): resolve all conflicts
1 parent cf35b96 commit 9d40428

20 files changed

+873
-737
lines changed

.vitepress/config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const ogImage = 'https://vitejs.dev/og-image.png'
55
const ogTitle = 'Vite'
66
const ogUrl = 'https://vitejs.dev'
77

8-
<<<<<<< HEAD
9-
=======
108
// netlify envs
119
const deployURL = process.env.DEPLOY_PRIME_URL || ''
1210
const commitRef = process.env.COMMIT_REF?.slice(0, 8) || 'dev'
@@ -62,7 +60,6 @@ const versionLinks = ((): DefaultTheme.NavItemWithLink[] => {
6260
}
6361
})()
6462

65-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
6663
export default defineConfig({
6764
title: 'Vite 官方中文文档',
6865
description: '下一代前端工具链',

.vitepress/rewrite-title/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const path = require('path')
2-
const fsp = require('fs').promises
3-
const matterService = require('../utils/frontmatter-service')
1+
import path from 'node:path'
2+
import fsp from 'node:fs/promises'
3+
import matterService from '../utils/frontmatter-service.js'
4+
import { fileURLToPath } from 'node:url'
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
46
const workspacePath = path.resolve(__dirname, '..', '..')
57

68
const h1MdRegExp = /^#\s+(.+)\s+(\{#([\w-]+)\})$/
@@ -41,4 +43,4 @@ const ergodicDirectory = async (dirPath) => {
4143
}
4244
}
4345

44-
module.exports = () => ergodicDirectory(workspacePath)
46+
export default () => ergodicDirectory(workspacePath)

.vitepress/theme/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ import './styles/vars.css'
55
import HomeSponsors from './components/HomeSponsors.vue'
66
import AsideSponsors from './components/AsideSponsors.vue'
77
import SvgImage from './components/SvgImage.vue'
8-
<<<<<<< HEAD
98
import WwAds from './components/WwAds.vue'
109
import './custom.css'
11-
=======
1210
// temporary fix for vitepress not including component css when only
1311
// imported in a single page
1412
import './components/BlogIndex.vue'
15-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
1613

1714
export default {
1815
extends: DefaultTheme,

.vitepress/utils/frontmatter-service.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const fs = require('fs')
2-
const matter = require('gray-matter')
3-
const { extend, isEmpty: _isEmpty } = require('lodash')
1+
import fs from 'node:fs'
2+
import matter from 'gray-matter'
3+
import _ from 'lodash'
4+
45
// gray-matter is a dep for vitepress,
56
// no need to specify that in package.json
67

@@ -21,7 +22,7 @@ class FrontMatterService {
2122
}
2223

2324
isEmpty() {
24-
return _isEmpty(this.matter.data)
25+
return _._isEmpty(this.matter.data)
2526
}
2627

2728
/** @param{(data: string) => void} callback */
@@ -48,7 +49,7 @@ class FrontMatterService {
4849

4950
/** @param {Record<string, any>} src */
5051
extend(src) {
51-
extend(this.matter.data, src)
52+
_.extend(this.matter.data, src)
5253
return this
5354
}
5455

@@ -63,4 +64,4 @@ class FrontMatterService {
6364
}
6465
}
6566

66-
module.exports = new FrontMatterService()
67+
export default new FrontMatterService()

config/server-options.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,10 @@ async function createServer() {
248248
server: { middlewareMode: true },
249249
appType: 'custom', // 不引入 Vite 默认的 HTML 处理中间件
250250
})
251-
<<<<<<< HEAD
252251
// 将 vite 的 connect 实例作中间件使用
253-
app.use(vite.middlewares)
254-
=======
255-
// Use vite's connect instance as middleware
256252
app.use((req, res, next) => {
257253
vite.middlewares.handle(req, res, next)
258254
})
259-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
260255

261256
app.use('*', async (req, res) => {
262257
// 由于 `appType` 的值是 `'custom'`,因此应在此处提供响应。

config/shared-options.md

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,15 @@
1111

1212
## base {#base}
1313

14-
<<<<<<< HEAD
1514
- **类型:** `string`
1615
- **默认:** `/`
17-
=======
18-
- **Type:** `string`
19-
- **Default:** `/`
20-
- **Related:** [`server.origin`](/config/server-options.md#server-origin)
21-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
16+
- **相关:** [`server.origin`](/config/server-options.md#server-origin)
2217

2318
开发或生产环境服务的公共基础路径。合法的值包括以下几种:
2419

25-
<<<<<<< HEAD
2620
- 绝对 URL 路径名,例如 `/foo/`
27-
- 完整的 URL,例如 `https://foo.com/`
21+
- 完整的 URL,例如 `https://foo.com/`(原始的部分在开发环境中不会被使用)
2822
- 空字符串或 `./`(用于嵌入形式的开发)
29-
=======
30-
- Absolute URL pathname, e.g. `/foo/`
31-
- Full URL, e.g. `https://foo.com/` (The origin part won't be used in development)
32-
- Empty string or `./` (for embedded deployment)
33-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
3423

3524
更多信息详见 [公共基础路径](/guide/build#public-base-path)
3625

@@ -176,29 +165,7 @@ Vite 有一个“允许的情景”列表,并且会匹配列表中第一个情
176165

177166
## css.modules {#css-modules}
178167

179-
<<<<<<< HEAD
180168
- **类型:**
181-
```ts
182-
interface CSSModulesOptions {
183-
scopeBehaviour?: 'global' | 'local'
184-
globalModulePaths?: RegExp[]
185-
generateScopedName?:
186-
| string
187-
| ((name: string, filename: string, css: string) => string)
188-
hashPrefix?: string
189-
/**
190-
* 默认:null
191-
*/
192-
localsConvention?:
193-
| 'camelCase'
194-
| 'camelCaseOnly'
195-
| 'dashes'
196-
| 'dashesOnly'
197-
| null
198-
}
199-
```
200-
=======
201-
- **Type:**
202169
```ts
203170
interface CSSModulesOptions {
204171
getJSON?: (
@@ -228,7 +195,6 @@ interface CSSModulesOptions {
228195
) => string)
229196
}
230197
```
231-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
232198

233199
配置 CSS modules 的行为。选项将被传递给 [postcss-modules](https://github.com/css-modules/postcss-modules)
234200

guide/api-javascript.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url))
3838
当在同一个 Node.js 进程中使用 `createServer``build` 时,两个函数都依赖于 `process.env.NODE_ENV` 才可正常工作,而这个环境变量又依赖于 `mode` 配置项。为了避免行为冲突,请在使用这两个 API 时为 `process.env.NODE_ENV` 或者 `mode` 配置项、字段设置参数值 `development`,或者你也可以生成另一个子进程,分别运行这两个 API
3939
:::
4040

41-
<<<<<<< HEAD
42-
## `InlineConfig` {#inlineconfig}
43-
=======
44-
::: tip NOTE
45-
When using [middleware mode](/config/server-options.html#server-middlewaremode) combined with [proxy config for WebSocket](/config/server-options.html#server-proxy), the parent http server should be provided in `middlewareMode` to bind the proxy correctly.
41+
::: tip 注意
42+
当使用 [中间件模式](/config/server-options.md#server-middlewaremode) 与 [WebSocket 代理配置](/config/server-options.md#server-proxy) 时,父 http 服务器应该在 `middlewareMode` 中提供,以正确绑定代理。
4643

4744
<details>
48-
<summary>Example</summary>
45+
<summary>示例</summary>
4946

5047
```ts
5148
import http from 'http'
@@ -55,9 +52,9 @@ const parentServer = http.createServer() // or express, koa, etc.
5552
5653
const vite = await createServer({
5754
server: {
58-
// Enable middleware mode
55+
// 开启中间件模式
5956
middlewareMode: {
60-
// Provide the parent http server for proxy WebSocket
57+
// 提供父 http 服务器以代理 WebSocket
6158
server: parentServer,
6259
},
6360
},
@@ -78,8 +75,7 @@ server.use((req, res, next) => {
7875
</details>
7976
:::
8077

81-
## `InlineConfig`
82-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
78+
## `InlineConfig` {#inlineconfig}
8379

8480
`InlineConfig` 接口扩展了 `UserConfig` 并添加了以下属性:
8581

guide/build.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,8 @@ dist/my-lib.umd.cjs 0.30 kB / gzip: 0.16 kB
216216
如果 `package.json` 不包含 `"type": "module"`,Vite 会生成不同的文件后缀名以兼容 Node.js。`.js` 会变为 `.mjs``.cjs` 会变为 `.js`
217217
:::
218218

219-
<<<<<<< HEAD
220219
::: tip 环境变量
221-
在库模式下,所有 `import.meta.env.*` 用法在构建生产时都会被静态替换。但是,`process.env.*` 的用法不会被替换,所以你的库的使用者可以动态地更改它。如果不想允许他们这样做,你可以使用 `define: { 'process.env.NODE_ENV': '"production"' }` 例如静态替换它们。
222-
=======
223-
::: tip Environment Variables
224-
In library mode, all [`import.meta.env.*`](./env-and-mode.md) usage are statically replaced when building for production. However, `process.env.*` usage are not, so that consumers of your library can dynamically change it. If this is undesirable, you can use `define: { 'process.env.NODE_ENV': '"production"' }` for example to statically replace them, or use [`esm-env`](https://github.com/benmccann/esm-env) for better compatibility with bundlers and runtimes.
225-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
220+
在库模式中,所有 [`import.meta.env.*`](./env-and-mode.md) 的使用都会在构建生产版本时被静态替换。但是,`process.env.*` 的使用不会,这样你的库的使用者就可以动态地改变它。如果这是不可取的,你可以使用 `define: { 'process.env.NODE_ENV': '"production"' }` 来静态替换它们,或者使用 [`esm-env`](https://github.com/benmccann/esm-env) 来更好地兼容打包工具和运行时。
226221
:::
227222

228223
::: warning 进阶用法

guide/dep-pre-bundling.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ export default defineConfig({
6060

6161
`include``exclude` 都可以用来处理这个问题。如果依赖项很大(包含很多内部模块)或者是 CommonJS,那么你应该包含它;如果依赖项很小,并且已经是有效的 ESM,则可以排除它,让浏览器直接加载它。
6262

63-
<<<<<<< HEAD
64-
你也可以使用 [`optimizeDeps.esbuildOptions` 选项](/config/dep-optimization-options.md#optimizedeps-esbuildoptions) 来进一步自定义 esbuild。例如,添加一个 esbuild 插件来处理依赖项中的特殊文件。
65-
=======
66-
You can further customize esbuild too with the [`optimizeDeps.esbuildOptions` option](/config/dep-optimization-options.md#optimizedeps-esbuildoptions). For example, adding an esbuild plugin to handle special files in dependencies or changing the [build `target`](https://esbuild.github.io/api/#target).
67-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
63+
你可以通过 [`optimizeDeps.esbuildOptions` 选项](/config/dep-optimization-options.md#optimizedeps-esbuildoptions) 进一步自定义 esbuild。例如,添加一个 esbuild 插件来处理依赖项中的特殊文件,或者更改 [build `target`](https://esbuild.github.io/api/#target)
6864

6965
## 缓存 {#caching}
7066

guide/env-and-mode.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,9 @@ Vite 还支持在 HTML 文件中替换环境变量。`import.meta.env` 中的任
107107
108108
如果环境变量在 `import.meta.env` 中不存在,比如不存在的 `%NON_EXISTENT%`,则会将被忽略而不被替换,这与 JS 中的 `import.meta.env.NON_EXISTENT` 不同,JS 中会被替换为 `undefined`
109109
110-
<<<<<<< HEAD
111-
## 模式 {#modes}
112-
=======
113-
Given that Vite is used by many frameworks, it is intentionally unopinionated about complex replacements like conditionals. Vite can be extended using [an existing userland plugin](https://github.com/vitejs/awesome-vite#transformers) or a custom plugin that implements the [`transformIndexHtml` hook](./api-plugin#transformindexhtml).
110+
正因为 Vite 被许多框架使用,它在复杂的替换(如条件替换)上故意不持任何意见。Vite 可以使用 [现有的用户插件](https://github.com/vitejs/awesome-vite#transformers) 或者一个实现了 [`transformIndexHtml` 钩子](./api-plugin#transformindexhtml) 的自定义插件来扩展。
114111
115-
## Modes
116-
>>>>>>> 8b72e23084a5bf4f2af26c9cef6ed2e89e20d001
112+
## 模式 {#modes}
117113
118114
默认情况下,开发服务器 (`dev` 命令) 运行在 `development` (开发) 模式,而 `build` 命令则运行在 `production` (生产) 模式。
119115

0 commit comments

Comments
 (0)