Skip to content

Commit 52832f4

Browse files
authored
Merge pull request #1176 from vitejs/sync-ebd74c77-1
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ ebd74c7
2 parents 053a3e4 + c22e614 commit 52832f4

File tree

13 files changed

+255
-236
lines changed

13 files changed

+255
-236
lines changed

.vitepress/config.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -307,19 +307,28 @@ export default defineConfig({
307307
sidebar: {
308308
'/guide/': [
309309
{
310-
text: '指引',
310+
text: '介绍',
311311
items: [
312312
{
313-
text: '为什么选 Vite',
314-
link: '/guide/why'
313+
text: '开始',
314+
link: '/guide/',
315315
},
316316
{
317-
text: '开始',
318-
link: '/guide/'
317+
text: '理念',
318+
link: '/guide/philosophy',
319319
},
320+
{
321+
text: '为什么选 Vite',
322+
link: '/guide/why',
323+
},
324+
],
325+
},
326+
{
327+
text: '指引',
328+
items: [
320329
{
321330
text: '功能',
322-
link: '/guide/features'
331+
link: '/guide/features',
323332
},
324333
{
325334
text: '命令行接口',
@@ -357,22 +366,14 @@ export default defineConfig({
357366
text: '后端集成',
358367
link: '/guide/backend-integration'
359368
},
360-
{
361-
text: '比较',
362-
link: '/guide/comparisons'
363-
},
364369
{
365370
text: '故障排除',
366-
link: '/guide/troubleshooting'
371+
link: '/guide/troubleshooting',
367372
},
368373
{
369374
text: '性能',
370375
link: '/guide/performance',
371376
},
372-
{
373-
text: '理念',
374-
link: '/guide/philosophy',
375-
},
376377
{
377378
text: '从 v5 迁移',
378379
link: '/guide/migration'

.vitepress/theme/components/landing/1. hero-section/HeroDiagram.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,8 @@ onMounted(() => {
520520
bottom: 0;
521521
transform: translate3d(0, 0, 0) scale(1);
522522
transition: transform 0.3s ease-in-out;
523-
background: linear-gradient(
523+
background:
524+
linear-gradient(
524525
130deg,
525526
rgba(61, 61, 61, 0.3) 0%,
526527
rgba(61, 61, 61, 0) 40%
@@ -713,7 +714,8 @@ onMounted(() => {
713714
opacity: 0.1;
714715
}
715716
716-
background: url('/noise.png'),
717+
background:
718+
url('/noise.png'),
717719
radial-gradient(
718720
circle at right center,
719721
rgb(86, 50, 119) 0%,
@@ -729,7 +731,8 @@ onMounted(() => {
729731
);
730732
731733
@media (min-width: 1024px) {
732-
background: url('/noise.png'),
734+
background:
735+
url('/noise.png'),
733736
radial-gradient(
734737
circle at right center,
735738
rgba(75, 41, 105, 0.5) 0%,
@@ -747,7 +750,8 @@ onMounted(() => {
747750
}
748751
749752
@media (min-width: 1500px) {
750-
background: url('/noise.png'),
753+
background:
754+
url('/noise.png'),
751755
radial-gradient(
752756
circle at right center,
753757
rgba(75, 41, 105, 0.5) 0%,
@@ -765,7 +769,8 @@ onMounted(() => {
765769
}
766770
767771
@media (min-width: 1800px) {
768-
background: url('/noise.png'),
772+
background:
773+
url('/noise.png'),
769774
radial-gradient(
770775
circle at right center,
771776
rgba(75, 41, 105, 0.5) 0%,

.vitepress/theme/components/landing/2. feature-section/FeatureInstantServerStart.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ onUnmounted(() => {
342342
bottom: 0;
343343
height: 100%;
344344
border-radius: 12px 0 0 12px;
345-
background: url('/noise.png'),
345+
background:
346+
url('/noise.png'),
346347
radial-gradient(
347348
ellipse 140% 80% at 96% bottom,
348349
#13b351 0%,

.vitepress/theme/composables/sponsor.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ const viteSponsors: Pick<Sponsors, 'special' | 'gold'> = {
4545
url: 'https://nuxtlabs.com',
4646
img: '/nuxtlabs.svg',
4747
},
48-
// sponsors bluwy
49-
{
50-
name: 'Astro',
51-
url: 'https://astro.build',
52-
img: '/astro.svg',
53-
},
5448
],
5549
gold: [
5650
// now automated via sponsors.vuejs.org too

.vitepress/theme/styles/landing.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ html:has(.landing) {
176176

177177
&.btn--primary {
178178
position: relative;
179-
background: radial-gradient(
179+
background:
180+
radial-gradient(
180181
141.42% 141.42% at 100% 0%,
181182
rgba(255, 255, 255, 0.4) 0%,
182183
rgba(255, 255, 255, 0) 100%
@@ -194,7 +195,8 @@ html:has(.landing) {
194195
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.75) inset;
195196

196197
&:hover {
197-
background: radial-gradient(
198+
background:
199+
radial-gradient(
198200
141.42% 141.42% at 100% 0%,
199201
rgba(255, 255, 255, 0.5) 0%,
200202
rgba(255, 255, 255, 0) 100%

_data/team.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const core = [
4545
avatar: 'https://github.com/bluwy.png',
4646
name: 'Bjorn Lu',
4747
title: 'Open Source Developer',
48-
desc: 'Vite, Astro, and Svelte core team member.',
48+
desc: 'Building tools for fun.',
4949
links: [
5050
{ icon: 'github', link: 'https://github.com/bluwy' },
5151
{ icon: 'bluesky', link: 'https://bsky.app/profile/bluwy.me' },

blog/announcing-vite2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Vite(法语意思是 “快”,发音为 `/vit/`,类似 veet)是一种
3333

3434
想知道 Vite 有多快?看看这个[视频比较](https://twitter.com/amasad/status/1355379680275128321), 在 Repl.it 上从零启动一个基于 Vite 的 React 应用,浏览器页面加载完毕的时候,基于 CRA(`create-react-app`)的应用甚至还没有安装完依赖。
3535

36-
如果你还没听说过 Vite 到底是什么,可以到 [这里](/guide/why) 了解一下项目的设计初衷。如果你想要了解 Vite 跟其它一些类似的工具有什么区别,可以参考这里的 [对比](/guide/comparisons)
36+
如果你还没听说过 Vite 到底是什么,可以到 [这里](/guide/why) 了解一下项目的设计初衷。如果你想要了解 Vite 跟其它一些类似的工具有什么区别,可以参考这里的 [对比](https://v5.vite.dev/guide/comparisons.html)
3737

3838
## 2.0 带来了什么 {#whats-new-in-2-0}
3939

guide/features.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,12 @@ export type { T }
7171

7272
- [TypeScript 文档](https://www.typescriptlang.org/tsconfig#useDefineForClassFields)
7373

74-
从 Vite v2.5.0 开始,如果 TypeScript 的 target 是 `ESNext``ES2022` 及更新版本,此选项默认值则为 `true`。这与 [`tsc` v4.3.2 及以后版本的行为](https://github.com/microsoft/TypeScript/pull/42663) 一致。这也是标准的 ECMAScript 的运行时行为
74+
如果 TypeScript 的 target 是 `ES2022` 或更高版本,包括 `ESNext`,那么默认值将为 `true`。这与 [TypeScript 4.3.2 及以后版本的行为](https://github.com/microsoft/TypeScript/pull/42663) 保持一致
7575

7676
若设了其他 TypeScript target,则本项会默认为 `false`.
7777

78-
但对于那些习惯其他编程语言或旧版本 TypeScript 的开发者来说,这可能是违反直觉的。
79-
你可以参阅 [TypeScript 3.7 发布日志](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier) 中了解更多关于如何兼容的信息。
80-
8178
如果你正在使用一个严重依赖 class fields 的库,请注意该库对此选项的预期设置。
82-
83-
大多数库都希望 `"useDefineForClassFields": true`,如 [MobX](https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties)
84-
85-
但是有几个库还没有兼容这个新的默认值,其中包括 [`lit-element`](https://github.com/lit/lit-element/issues/1030)。如果遇到这种情况,请将 `useDefineForClassFields` 设置为 `false`
79+
虽然大多数库期望 `"useDefineForClassFields": true`,但如果你的库不支持它,你可以明确地将 `useDefineForClassFields` 设置为 `false`
8680

8781
#### `target` {#target}
8882

@@ -124,20 +118,26 @@ Vite 默认的类型定义是写给它的 Node.js API 的。要将其补充到
124118
/// <reference types="vite/client" />
125119
```
126120

121+
::: details 使用 `compilerOptions.types`
122+
127123
或者,你也可以将 `vite/client` 添加到 `tsconfig.json` 中的 `compilerOptions.types` 下:
128124

129125
```json [tsconfig.json]
130126
{
131127
"compilerOptions": {
132-
"types": ["vite/client"]
128+
"types": ["vite/client", "some-other-global-lib"]
133129
}
134130
}
135131
```
136132

137-
这将会提供以下类型定义补充:
133+
需要注意的是,如果指定了 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig#types),则只有这些包会被包含在全局作用域内(而不是所有的“@types”包)。
134+
135+
:::
136+
137+
`vite/client` 会提供以下类型定义补充:
138138

139139
- 资源导入 (例如:导入一个 `.svg` 文件)
140-
- `import.meta.env` 上 Vite 注入的 [常量变量](./env-and-mode#env-variables) 的类型定义
140+
- `import.meta.env` 上 Vite 注入的 [常量](./env-and-mode#env-variables) 的类型定义
141141
- `import.meta.hot` 上的 [HMR API](./api-hmr) 类型定义
142142

143143
::: tip
@@ -204,22 +204,24 @@ HTML 文件位于 Vite 项目的[最前端和中心](/guide/#index-html-and-proj
204204

205205
要退出对某些元素的 HTML 处理,可以在元素上添加 `vite-ignore` 属性,这在引用外部 assets 或 CDN 时非常有用。
206206

207-
## Vue {#vue}
207+
## 框架支持 {#frameworks}
208+
209+
所有现代框架都已和 Vite 集成。大多数框架插件由各自的框架团队维护,唯有官方的 Vue 和 React Vite 插件由 Vite 组织维护。
208210

209-
Vite 为 Vue 提供第一优先级支持:
211+
- Vue 支持:[@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue)
212+
- Vue JSX 支持:[@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)
213+
- React 支持:[@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react)
214+
- React 使用 SWC 的支持:[@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc)
210215

211-
- Vue 3 单文件组件支持:[@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue)
212-
- Vue 3 JSX 支持:[@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)
213-
- Vue 2.7 SFC 支持:[@vitejs/plugin-vue2](https://github.com/vitejs/vite-plugin-vue2)
214-
- Vue 2.7 JSX 支持:[@vitejs/plugin-vue2-jsx](https://github.com/vitejs/vite-plugin-vue2-jsx)
216+
查看 [插件指南](/plugins/) 了解更多信息。
215217

216218
## JSX {#jsx}
217219

218220
`.jsx``.tsx` 文件同样开箱即用。JSX 的转译同样是通过 [esbuild](https://esbuild.github.io)
219221

220-
Vue 用户应使用官方提供的 [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) 插件,它提供了 Vue 3 特性的支持,包括 HMR,全局组件解析,指令和插槽。
222+
你选择的框架已经可以开箱即用地配置 JSX(例如,Vue 用户应使用官方的 [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) 插件,它提供了 Vue 3 特定的功能,包括 HMR,全局组件解析,指令和插槽
221223

222-
如果不是在 React 或 Vue 中使用 JSX,自定义的 `jsxFactory``jsxFragment` 可以使用 [`esbuild` 选项](/config/shared-options.md#esbuild) 进行配置。例如对 Preact:
224+
如果你使用自己的框架运行 JSX,可以使用 [`esbuild` 选项](/config/shared-options.md#esbuild) 来配置自定义的 `jsxFactory``jsxFragment`。例如,Preact 插件会使用
223225

224226
```js twoslash [vite.config.js]
225227
import { defineConfig } from 'vite'

guide/index.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,31 @@ Vite 也支持多个 `.html` 作入口点的 [多页面应用模式](./build#mul
202202

203203
## 使用未发布的功能 {#using-unreleased-commits}
204204

205-
如果你迫不及待想要体验最新的功能,可以自行克隆 [vite 仓库](https://github.com/vitejs/vite) 到本地机器上然后自行将其链接(将需要 [pnpm](https://pnpm.io/)):
205+
如果你迫不及待想要体验最新的功能,可以使用 https://pkg.pr.new 安装特定的 Vite 提交:
206+
207+
::: code-group
208+
209+
```bash [npm]
210+
$ npm install -D https://pkg.pr.new/vite@SHA
211+
```
212+
213+
```bash [Yarn]
214+
$ yarn add -D https://pkg.pr.new/vite@SHA
215+
```
216+
217+
```bash [pnpm]
218+
$ pnpm add -D https://pkg.pr.new/vite@SHA
219+
```
220+
221+
```bash [Bun]
222+
$ bun add -D https://pkg.pr.new/vite@SHA
223+
```
224+
225+
:::
226+
227+
`SHA` 替换为 [Vite 的提交 SHA](https://github.com/vitejs/vite/commits/main/)。请注意,仅最近一个月的提交有效,旧版本提交的构建产物会被清除。
228+
229+
或者,你可以克隆 [Vite 代码仓库](https://github.com/vitejs/vite) 到本地,自行构建并建立软链接(需安装 [pnpm](https://pnpm.io/)):
206230

207231
```bash
208232
git clone https://github.com/vitejs/vite.git
@@ -215,6 +239,10 @@ pnpm link --global # 在这一步中可使用你喜欢的包管理器
215239

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

242+
::: tip 处理依赖中的 Vite 版本
243+
若需替换依赖链中传递使用的 Vite 版本(Transitive Dependencies),应使用 [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides)[pnpm overrides](https://pnpm.io/package_json#pnpmoverrides)
244+
:::
245+
218246
## 社区 {#community}
219247

220248
如果你有疑问或者需要帮助,可以到 [Discord](https://chat.vite.dev)[GitHub Discussions](https://github.com/vitejs/vite/discussions) 社区来寻求帮助。

guide/why.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Vite 目前的插件 API 与使用 `esbuild` 作为打包器并不兼容。尽
5757

5858
Rollup 已经开始着手改进性能,[在 v4 中将其解析器切换到 SWC](https://github.com/rollup/rollup/pull/5073)。同时还有一个正在进行中的工作,即构建一个名为 Rolldown 的 Rust 版本的 Rollup。一旦 Rolldown 准备就绪,它就可以在 Vite 中取代 Rollup 和 esbuild,显著提高构建性能,并消除开发和构建之间的不一致性。你可以观看 [Evan You 在 ViteConf 2023 的主题演讲](https://youtu.be/hrdwQHoAp0M) 了解更多细节。
5959

60-
## Vite 与 X 的区别是? {#how-is-vite-different-from-x}
60+
## Vite 与其他免打包构建工具的关系是什么?{##how-vite-relates-to-other-unbundled-build-tools}
6161

62-
你可以查看 [比较](./comparisons.md) 章节获取更多细节,了解 Vite 与同类工具的异同。
62+
Preact 团队的 [WMR](https://github.com/preactjs/wmr) 旨在提供类似的功能集。Vite 用于开发和构建的通用 Rollup 插件 API 就是受其启发。WMR 已经不再维护。Preact 团队现在推荐使用 Vite 和 [@preactjs/preset-vite](https://github.com/preactjs/preset-vite)
63+
64+
[Snowpack](https://www.snowpack.dev/) 也是一个免打包的原生 ESM 开发服务器,与 Vite 的职责非常相似。Vite 的依赖预打包也受到了 Snowpack v1(现在是 [`esinstall`](https://github.com/snowpackjs/snowpack/tree/main/esinstall))的启发。Snowpack 已经不再维护。Snowpack 团队现在正在研究由 Vite 驱动的静态网站构建器 [Astro](https://astro.build/)
65+
66+
[@web/dev-server](https://modern-web.dev/docs/dev-server/overview/)(以前是 `es-dev-server`)是一个伟大的项目,Vite 1.0 的基于 Koa 的服务器设置就是受其启发。`@web` 这个项目正在积极维护,并包含许多其他优秀的工具,这些工具也可能对 Vite 用户有所帮助。

0 commit comments

Comments
 (0)