Skip to content

docs: update content #1325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import {
groupIconMdPlugin,
groupIconVitePlugin,
} from 'vitepress-plugin-group-icons'
<<<<<<< HEAD
=======
import llmstxt from 'vitepress-plugin-llms'
import type { PluginOption } from 'vite'
import { markdownItImageSize } from 'markdown-it-image-size'
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
import { buildEnd } from './buildEnd.config'

const ogDescription = 'Next Generation Frontend Tooling'
Expand Down
6 changes: 1 addition & 5 deletions changes/ssr-using-modulerunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

## 迁移指南 {#migration-guide}

<<<<<<< HEAD
请查看 [用于框架的环境 API 指南](../guide/api-environment-frameworks.md)。
=======
Check out the [Environment API for Frameworks Guide](../guide/api-environment-frameworks.md).

`server.ssrFixStacktrace` and `server.ssrRewriteStacktrace` does not have to be called when using the Module Runner APIs. The stack traces will be updated unless `sourcemapInterceptor` is set to `false`.
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
当使用 Module Runner API 时,不再需要调用 `server.ssrFixStacktrace` 和 `server.ssrRewriteStacktrace`。除非 `sourcemapInterceptor` 被设置为 `false`,否则堆栈追踪信息将会自动更新。
36 changes: 6 additions & 30 deletions config/dep-optimization-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@

如果这两者都不合你意,则可以使用此选项指定自定义条目——该值需要遵循 [tinyglobby 模式](https://github.com/SuperchupuDev/tinyglobby) ,或者是相对于 Vite 项目根目录的匹配模式数组。当显式声明了 `optimizeDeps.entries` 时默认只有 `node_modules` 和 `build.outDir` 文件夹会被忽略。如果还需忽略其他文件夹,你可以在模式列表中使用以 `!` 为前缀的、用来匹配忽略项的模式。对于明确包含字符串 `node_modules` 的模式,不会忽略 `node_modules`。

<<<<<<< HEAD
## optimizeDeps.exclude {#optimizedeps-exclude}
=======
## optimizeDeps.exclude <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.exclude <NonInheritBadge /> {#optimizedeps-exclude}

- **类型:** `string[]`

Expand All @@ -37,11 +33,7 @@ export default defineConfig({

:::

<<<<<<< HEAD
## optimizeDeps.include {#optimizedeps-include}
=======
## optimizeDeps.include <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.include <NonInheritBadge /> {#optimizedeps-include}

- **类型:** `string[]`

Expand All @@ -59,11 +51,7 @@ export default defineConfig({
})
```

<<<<<<< HEAD
## optimizeDeps.esbuildOptions {#optimizedeps-esbuild-options}
=======
## optimizeDeps.esbuildOptions <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.esbuildOptions <NonInheritBadge /> {#optimizedeps-esbuild-options}

- **类型:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`[`EsbuildBuildOptions`](https://esbuild.github.io/api/#general-options)`,
| 'bundle'
Expand All @@ -84,21 +72,13 @@ export default defineConfig({
- 忽略了 `external` 选项,请使用 Vite 的 `optimizeDeps.exclude` 选项
- `plugins` 与 Vite 的 dep 插件合并

<<<<<<< HEAD
## optimizeDeps.force {#optimizedeps-force}
=======
## optimizeDeps.force <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.force <NonInheritBadge /> {#optimizedeps-force}

- **类型:** `boolean`

设置为 `true` 可以强制依赖预构建,而忽略之前已经缓存过的、已经优化过的依赖。

<<<<<<< HEAD
## optimizeDeps.noDiscovery {#optimizedeps-no-discovery}
=======
## optimizeDeps.noDiscovery <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.noDiscovery <NonInheritBadge /> {#optimizedeps-no-discovery}

- **类型:** `boolean`
- **默认:** `false`
Expand All @@ -113,11 +93,7 @@ export default defineConfig({

当该功能被启用时,系统会在冷启动时保持第一个优化的依赖结果,直到所有的静态导入都被检索完毕。这样可以避免因为发现新的依赖项而触发新的公共 chunk 生成,从而需要刷新整个页面。如果通过扫描和在 `include` 中明确定义的方式能找到所有的依赖项,那么最好关闭这个功能,这样浏览器可以并行处理更多的请求。

<<<<<<< HEAD
## optimizeDeps.disabled {#optimizedeps-disabled}
=======
## optimizeDeps.disabled <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## optimizeDeps.disabled <NonInheritBadge /> {#optimizedeps-disabled}

- **已废弃**
- **实验性:** [提供反馈](https://github.com/vitejs/vite/discussions/13839)
Expand Down
6 changes: 1 addition & 5 deletions config/preview-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ export default defineConfig({

为开发服务器配置自定义代理规则。其值的结构为 `{ key: options }` 的对象。如果 key 以 `^` 开头,它将被识别为 `RegExp`,其中 `configure` 选项可用于访问代理实例。

<<<<<<< HEAD
基于 [`http-proxy`](https://github.com/http-party/node-http-proxy) 实现,完整的参数列表参见 [此链接](https://github.com/http-party/node-http-proxy#options)。
=======
Uses [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3). Full options [here](https://github.com/sagemathinc/http-proxy-3#options).
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
基于 [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3) 实现,完整的参数列表参见 [此链接](https://github.com/sagemathinc/http-proxy-3#options)。

## preview.cors {#preview-cors}

Expand Down
6 changes: 1 addition & 5 deletions config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ export default defineConfig({

请注意,如果使用了非相对的 [基础路径 `base`](/config/shared-options.md#base),则必须在每个 key 值前加上该 `base`

<<<<<<< HEAD
继承自 [`http-proxy`](https://github.com/http-party/node-http-proxy#options)。完整选项详见 [此处](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13)
=======
Extends [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3#options). Additional options are [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13).
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
继承自 [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3#options)。完整选项详见 [此处](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13)

在某些情况下,你可能也想要配置底层的开发服务器。(例如添加自定义的中间件到内部的 [connect](https://github.com/senchalabs/connect) 应用中)为了实现这一点,你需要编写你自己的 [插件](/guide/using-plugins.html) 并使用 [configureServer](/guide/api-plugin.html#configureserver) 函数。

Expand Down
12 changes: 2 additions & 10 deletions config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ declare const __APP_VERSION__: string
对于服务端渲染构建,配置项 `build.rollupOptions.output` 为 ESM 构建输出时去重过程将不工作。一个替代方案是先使用 CJS 构建输出,直到 ESM 在插件中有了更好的模块加载支持。
:::
<<<<<<< HEAD
## resolve.conditions {#resolve-conditions}
=======
## resolve.conditions <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## resolve.conditions <NonInheritBadge /> {#resolve-conditions}
- **类型:** `string[]`
- **默认:** `['module', 'browser', 'development|production']` (`defaultClientConditions`)
Expand All @@ -144,11 +140,7 @@ declare const __APP_VERSION__: string

请注意,如果符合要求,`import``require``default` 始终会被应用。

<<<<<<< HEAD
## resolve.mainFields {#resolve-mainfields}
=======
## resolve.mainFields <NonInheritBadge />
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
## resolve.mainFields <NonInheritBadge /> {#resolve-mainfields}

- **类型:** `string[]`
- **默认:** `['browser', 'module', 'jsnext:main', 'jsnext']` (`defaultClientMainFields`)
Expand Down
6 changes: 1 addition & 5 deletions guide/api-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ export default {
}
```

<<<<<<< HEAD
如果没有明确说明,环境将继承已配置的顶级配置选项(例如,新的 `server``edge` 环境将继承 `build.sourcemap: false` 选项)。少数顶级选项(如 `optimizeDeps`)仅适用于 `client` 环境,因为它们在默认应用于服务器环境时效果不佳。也可以通过 `environments.client` 明确配置 `client` 环境,但我们建议使用顶级选项进行配置,以便在添加新环境时客户端配置保持不变。
=======
When not explicitly documented, environment inherits the configured top-level config options (for example, the new `server` and `edge` environments will inherit the `build.sourcemap: false` option). A small number of top-level options, like `optimizeDeps`, only apply to the `client` environment, as they don't work well when applied as a default to server environments. Those options have <NonInheritBadge /> badge in [the reference](/config/). The `client` environment can also be configured explicitly through `environments.client`, but we recommend to do it with the top-level options so the client config remains unchanged when adding new environments.
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
如果没有明确说明,环境将继承已配置的顶级配置选项(例如,新的 `server``edge` 环境将继承 `build.sourcemap: false` 选项)。少数顶级选项(如 `optimizeDeps`)仅适用于 `client` 环境,因为它们在默认应用于服务器环境时效果不佳。这些选项在[配置参考](/config/)中带有 <NonInheritBadge /> 标记。也可以通过 `environments.client` 明确配置 `client` 环境,但我们建议使用顶级选项进行配置,以便在添加新环境时客户端配置保持不变。

`EnvironmentOptions` 接口公开所有每个环境选项。有些环境选项适用于 `build``dev`,如 `resolve`。还有 `DevEnvironmentOptions``BuildEnvironmentOptions` 用于开发和构建特定选项(如 `dev.warmup``build.outDir`)。一些选项(例如`optimizeDeps`)仅适用于 dev,但为了向后兼容,它保留为顶层而不是嵌套在`dev`中。

Expand Down
5 changes: 0 additions & 5 deletions guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请
当创作插件时,你可以在 `vite.config.js` 中直接使用它。没必要直接为它创建一个新的 package。当你发现某个插件在你项目中很有用时,可以考虑 [在社区中](https://chat.vite.dev) 将其与他人分享。

::: tip
<<<<<<< HEAD
在学习、调试或创作插件时,我们建议在你的项目中引入 [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect)。 它可以帮助你检查 Vite 插件的中间状态。安装后,你可以访问 `localhost:5173/__inspect/` 来检查你项目的模块和栈信息。请查阅 [vite-plugin-inspect 文档](https://github.com/antfu/vite-plugin-inspect) 中的安装说明。
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
=======
When learning, debugging, or authoring plugins, we suggest including [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect) in your project. It allows you to inspect the intermediate state of Vite plugins. After installing, you can visit `localhost:5173/__inspect/` to inspect the modules and transformation stack of your project. Check out install instructions in the [vite-plugin-inspect docs](https://github.com/antfu/vite-plugin-inspect).
![vite-plugin-inspect](../images/vite-plugin-inspect.png)
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
:::

## 约定 {#conventions}
Expand Down
11 changes: 1 addition & 10 deletions guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

## 总览 {#overview}

<<<<<<< HEAD
Vite(法语意为 "快速的",发音 `/vit/`<button id="play-vite-audio" onclick="document.getElementById('vite-audio').play();" style="border: none; padding: 3px; border-radius: 4px; vertical-align: bottom;"><svg style="height:2em;width:2em"><use href="/voice.svg?no-inline#voice" /></svg></button>,发音同 "veet")是一种新型前端构建工具,能够显著提升前端开发体验。它主要由两部分组成:
=======
Vite (French word for "quick", pronounced `/vit/`<button style="border:none;padding:3px;border-radius:4px;vertical-align:bottom" id="play-vite-audio" aria-label="pronounce" onclick="document.getElementById('vite-audio').play();"><svg style="height:2em;width:2em"><use href="/voice.svg?no-inline#voice" /></svg></button>, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects. It consists of two major parts:
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe

- 一个开发服务器,它基于 [原生 ES 模块](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) 提供了 [丰富的内建功能](./features),如速度快到惊人的 [模块热替换(HMR)](./features#hot-module-replacement)。

Expand Down Expand Up @@ -259,13 +255,8 @@ pnpm link --global # 在这一步中可使用你喜欢的包管理器

然后,回到你的 Vite 项目并运行 `pnpm link --global vite`(或者使用你的其他包管理工具来全局链接 `vite`)。重新启动开发服务器来体验新功能吧!

<<<<<<< HEAD
::: tip 处理依赖中的 Vite 版本
若需替换依赖链中传递使用的 Vite 版本(Transitive Dependencies),应使用 [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) 或 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides)。
=======
::: tip Dependencies using Vite
To replace the Vite version used by dependencies transitively, you should use [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) or [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides).
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
若需替换依赖链中传递使用的 Vite 版本(Transitive Dependencies),应使用 [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) 或 [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides)。
:::

## 社区 {#community}
Expand Down
6 changes: 1 addition & 5 deletions guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ import './Foo.js' // 应该为 './foo.js'

### 链接本地包时过期预构建依赖项 {#outdated-pre-bundled-deps-when-linking-to-a-local-package}

<<<<<<< HEAD
在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) 和 [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。
=======
The hash key used to invalidate optimized dependencies depends on the package lock contents, the patches applied to dependencies, and the options in the Vite config file that affects the bundling of node modules. This means that Vite will detect when a dependency is overridden using a feature as [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides), and re-bundle your dependencies on the next server start. Vite won't invalidate the dependencies when you use a feature like [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link). In case you link or unlink a dependency, you'll need to force re-optimization on the next server start by using `vite --force`. We recommend using overrides instead, which are supported now by every package manager (see also [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides) and [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions)).
>>>>>>> 4e86b4da5ae0e07dc033a7c4352a9a2fb70acafe
在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides) 和 [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。

## 性能瓶颈 {#performance-bottlenecks}

Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
"license": "CC BY-NC-SA 4.0",
"devDependencies": {
"@shikijs/vitepress-twoslash": "^3.7.0",
"@type-challenges/utils": "^0.1.1",
"@types/express": "^5.0.3",
"feed": "^5.1.0",
"vitepress": "^2.0.0-alpha.7",
"vitepress-plugin-group-icons": "^1.6.1",
"vue": "3.6.0-alpha.1",
"@types/node": "^20.9.2",
"@type-challenges/utils": "^0.1.1",
"chalk": "^4.1.2",
"feed": "^5.1.0",
"gray-matter": "^4.0.3",
"gsap": "^3.13.0",
"lodash": "^4.17.21",
"markdown-it-image-size": "^14.7.0",
"vite": "^7.0.4",
"yorkie": "^2.0.0",
"gsap": "^3.13.0"
"vitepress": "^2.0.0-alpha.7",
"vitepress-plugin-group-icons": "^1.6.1",
"vitepress-plugin-llms": "^1.7.1",
"vue": "3.6.0-alpha.1",
"yorkie": "^2.0.0"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading