From 8cef664b0ba406caaf7d513f748588ce1959a608 Mon Sep 17 00:00:00 2001 From: Kylin <1159469891@qq.com> Date: Tue, 23 Sep 2025 20:25:36 +0800 Subject: [PATCH] docs: update content --- guide/api-hmr.md | 8 +------- guide/env-and-mode.md | 8 ++------ guide/features.md | 22 +++------------------- guide/rolldown.md | 8 ++------ 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/guide/api-hmr.md b/guide/api-hmr.md index c4af7111..a4b8b7bd 100644 --- a/guide/api-hmr.md +++ b/guide/api-hmr.md @@ -60,14 +60,8 @@ if (import.meta.hot) { } ``` -<<<<<<< HEAD ## TypeScript 的智能提示 {#intellisense-for-typescript} -Vite 在 [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts) 中为 `import.meta.hot` 提供了类型定义。你可以在 `src` 目录中创建一个 `vite-env.d.ts`,以便 TypeScript 获取类型定义: -======= -## IntelliSense for TypeScript - -Vite provides type definitions for `import.meta.hot` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). You can add "vite/client" in the `tsconfig.json` so TypeScript picks up the type definitions: ->>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3 +Vite 在 [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts) 中为 `import.meta.hot` 提供了类型定义。你可以在 `tsconfig.json` 中添加 "vite/client",以便 TypeScript 获取这些类型定义: ```json [tsconfig.json] { diff --git a/guide/env-and-mode.md b/guide/env-and-mode.md index 0fd02b95..c3d635a7 100644 --- a/guide/env-and-mode.md +++ b/guide/env-and-mode.md @@ -2,22 +2,18 @@ Vite 在特殊的 `import.meta.env` 对象下暴露了一些常量。这些常量在开发阶段被定义为全局变量,并在构建阶段被静态替换,以使树摇(tree-shaking)更有效。 -<<<<<<< HEAD -## 内置常量 {#built-in-constants} -======= :::details Example ```js if (import.meta.env.DEV) { - // code inside here will be tree-shaken in production builds + // 这里的代码在生产构建中会被 tree-shaking 优化掉 console.log('Dev mode') } ``` ::: -## Built-in Constants ->>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3 +## 内置常量 {#built-in-constants} 一些内置常量在所有情况下都可用: diff --git a/guide/features.md b/guide/features.md index 520f55cd..f795e806 100644 --- a/guide/features.md +++ b/guide/features.md @@ -113,19 +113,7 @@ Vite 启动模板默认情况下会设置 `"skipLibCheck": "true"`,以避免 ### 客户端类型 {#client-types} -<<<<<<< HEAD -Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到一个 Vite 应用的客户端代码环境中,请添加一个 `d.ts` 声明文件: - -```typescript -/// -``` - -::: details 使用 `compilerOptions.types` - -或者,你也可以将 `vite/client` 添加到 `tsconfig.json` 中的 `compilerOptions.types` 下: -======= -Vite's default types are for its Node.js API. To shim the environment of client-side code in a Vite application, you can add `vite/client` to `compilerOptions.types` inside `tsconfig.json`: ->>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3 +Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到一个 Vite 应用的客户端代码环境中,你可以在 `tsconfig.json` 中的 `compilerOptions.types` 添加 `vite/client`: ```json [tsconfig.json] { @@ -135,19 +123,15 @@ Vite's default types are for its Node.js API. To shim the environment of client- } ``` -<<<<<<< HEAD -需要注意的是,如果指定了 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types),则只有这些包会被包含在全局作用域内(而不是所有的“@types”包)。 -======= -Note that if [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types) is specified, only these packages will be included in the global scope (instead of all visible ”@types” packages). This is recommended since TS 5.9. +需要注意的是,如果指定了 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types),则只有这些包会被包含在全局作用域内(而不是所有的“@types”包)。这是自 TypeScript 5.9 以来推荐的做法。 ::: details Using triple-slash directive -Alternatively, you can add a `d.ts` declaration file: +或者,你可以添加一个 `d.ts` 声明文件: ```typescript [vite-env.d.ts] /// ``` ->>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3 ::: diff --git a/guide/rolldown.md b/guide/rolldown.md index 203a70ec..8cde023b 100644 --- a/guide/rolldown.md +++ b/guide/rolldown.md @@ -85,13 +85,9 @@ Rolldown 专注于三个主要原则: 在添加 overrides 之后,重新安装你的依赖并像往常一样启动你的开发服务器或构建你的项目即可,无需进一步的配置更改。 -<<<<<<< HEAD -## 已知限制 {#known-limitations} -======= -If you are starting a new project, you can use `create-vite` as normal for rolldown-vite, too. The latest version will ask you whether to use `rolldown-vite` or not. +如果你正在启动一个新项目,你也可以像平常一样使用 `create-vite` 来创建 rolldown-vite 项目。最新版本会询问你是否要使用 `rolldown-vite`。 -## Known Limitations ->>>>>>> 8885216737ac0478e1ca5271dd1a259d9fdadde3 +## 已知限制 {#known-limitations} 虽然 Rolldown 的目标是成为 Rollup 的替代品,但还有一些特性正在实现中,以及一些小的有意的行为差异。需要查看完整的列表,请参考 [这个 GitHub PR](https://github.com/vitejs/rolldown-vite/pull/84#issue-2903144667),它会定期更新。