You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
想知道 Vite 有多快?看看这个[视频比较](https://twitter.com/amasad/status/1355379680275128321), 在 Repl.it 上从零启动一个基于 Vite 的 React 应用,浏览器页面加载完毕的时候,基于 CRA(`create-react-app`)的应用甚至还没有安装完依赖。
35
35
36
-
<<<<<<< HEAD
37
-
如果你还没听说过 Vite 到底是什么,可以到 [这里](/guide/why) 了解一下项目的设计初衷。如果你想要了解 Vite 跟其它一些类似的工具有什么区别,可以参考这里的 [对比](/guide/comparisons)。
38
-
=======
39
-
If you've never heard of Vite before and would love to learn more about it, check out [the rationale behind the project](https://vite.dev/guide/why.html). If you are interested in how Vite differs from other similar tools, check out the [comparisons](https://v5.vite.dev/guide/comparisons.html).
40
-
>>>>>>> ebd74c77072778dd0436838f2b46ccda4e5fed79
36
+
如果你还没听说过 Vite 到底是什么,可以到 [这里](/guide/why) 了解一下项目的设计初衷。如果你想要了解 Vite 跟其它一些类似的工具有什么区别,可以参考这里的 [对比](https://v5.vite.dev/guide/comparisons.html)。
The default value will be `true` if the TypeScript target is `ES2022` or newer including `ESNext`. It is consistent with the [behavior of TypeScript 4.3.2+](https://github.com/microsoft/TypeScript/pull/42663).
89
-
Other TypeScript targets will default to `false`.
90
-
91
-
`true` is the standard ECMAScript runtime behavior.
92
-
93
-
If you are using a library that heavily relies on class fields, please be careful about the library's intended usage of it.
94
-
While most libraries expect `"useDefineForClassFields": true`, you can explicitly set `useDefineForClassFields` to `false` if your library doesn't support it.
@@ -150,23 +130,15 @@ Alternatively, you can add `vite/client` to `compilerOptions.types` inside `tsco
150
130
}
151
131
```
152
132
153
-
<<<<<<< HEAD
154
-
这将会提供以下类型定义补充:
155
-
156
-
- 资源导入 (例如:导入一个 `.svg` 文件)
157
-
-`import.meta.env` 上 Vite 注入的 [常量变量](./env-and-mode#env-variables) 的类型定义
158
-
-`import.meta.hot` 上的 [HMR API](./api-hmr) 类型定义
159
-
=======
160
-
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).
All modern frameworks maintain integrations with Vite. Most framework plugins are maintained by each framework team, with the exception of the official Vue and React Vite plugins that are maintained in the vite org:
248
-
249
-
- Vue support via [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue)
250
-
- Vue JSX support via [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)
251
-
- React support via [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react)
252
-
- React using SWC support via [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc)
253
-
254
-
Check out the [Plugins Guide](https://vite.dev/plugins) for more information.
Your framework of choice will already configure JSX out of the box (for example, Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots).
If using JSX with your own framework, custom `jsxFactory` and `jsxFragment` can be configured using the [`esbuild` option](/config/shared-options.md#esbuild). For example, the Preact plugin would use:
If you can't wait for a new release to test the latest features, you can install a specific commit of Vite with https://pkg.pr.new:
205
+
如果你迫不及待想要体验最新的功能,可以使用 https://pkg.pr.new 安装特定的 Vite 提交:
209
206
210
207
::: code-group
211
208
@@ -227,10 +224,9 @@ $ bun add -D https://pkg.pr.new/vite@SHA
227
224
228
225
:::
229
226
230
-
Replace`SHA`with any of [Vite's commit SHAs](https://github.com/vitejs/vite/commits/main/). Note that only commits within the last month will work, as older commit releases are purged.
Alternatively, you can also clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([pnpm](https://pnpm.io/) is required):
@@ -243,14 +239,10 @@ pnpm link --global # 在这一步中可使用你喜欢的包管理器
243
239
244
240
然后,回到你的 Vite 项目并运行 `pnpm link --global vite`(或者使用你的其他包管理工具来全局链接 `vite`)。重新启动开发服务器来体验新功能吧!
245
241
246
-
<<<<<<< HEAD
247
-
## 社区 {#community}
248
-
=======
249
-
::: tip Dependencies using Vite
250
-
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/package_json#pnpmoverrides).
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)。
## Vite 与其他免打包构建工具的关系是什么?{##how-vite-relates-to-other-unbundled-build-tools}
62
61
63
-
你可以查看 [比较](./comparisons.md) 章节获取更多细节,了解 Vite 与同类工具的异同。
64
-
=======
65
-
## How Vite Relates to Other Unbundled Build Tools?
62
+
Preact 团队的 [WMR](https://github.com/preactjs/wmr) 旨在提供类似的功能集。Vite 用于开发和构建的通用 Rollup 插件 API 就是受其启发。WMR 已经不再维护。Preact 团队现在推荐使用 Vite 和 [@preactjs/preset-vite](https://github.com/preactjs/preset-vite)。
66
63
67
-
[WMR](https://github.com/preactjs/wmr) by the Preact team looked to provide a similar feature set. Vite's universal Rollup plugin API for dev and build was inspired by it. WMR is no longer maintained. The Preact team now recommends Vite with [@preactjs/preset-vite](https://github.com/preactjs/preset-vite).
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/)。
68
65
69
-
[Snowpack](https://www.snowpack.dev/) was also a no-bundle native ESM dev server, very similar in scope to Vite. Vite's dependency pre-bundling is also inspired by Snowpack v1 (now [`esinstall`](https://github.com/snowpackjs/snowpack/tree/main/esinstall)). Snowpack is no longer being maintained. The Snowpack team is now working on [Astro](https://astro.build/), a static site builder powered by Vite.
70
-
71
-
[@web/dev-server](https://modern-web.dev/docs/dev-server/overview/) (previously `es-dev-server`) is a great project and Vite 1.0's Koa-based server setup was inspired by it. The `@web` umbrella project is actively maintained and contains many other excellent tools that may benefit Vite users as well.
72
-
>>>>>>> ebd74c77072778dd0436838f2b46ccda4e5fed79
66
+
[@web/dev-server](https://modern-web.dev/docs/dev-server/overview/)(以前是 `es-dev-server`)是一个伟大的项目,Vite 1.0 的基于 Koa 的服务器设置就是受其启发。`@web` 这个项目正在积极维护,并包含许多其他优秀的工具,这些工具也可能对 Vite 用户有所帮助。
0 commit comments