File tree 3 files changed +26
-18
lines changed
3 files changed +26
-18
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,7 @@ export default defineConfig(async ({ command, mode }) => {
376
376
### server.port {#server-port}
377
377
378
378
- ** 类型:** ` number `
379
+ - ** 默认值:** ` 3000 `
379
380
380
381
指定开发服务器端口。注意:如果端口已经被使用,Vite 会自动尝试下一个可用的端口,所以这可能不是开发服务器最终监听的实际端口。
381
382
@@ -483,7 +484,7 @@ export default defineConfig(async ({ command, mode }) => {
483
484
484
485
当需要再 Windows Subsystem for Linux (WSL) 2 上运行 Vite 时,如果项目文件夹位于 Windows 文件系统中,你需要将此选项设置为 ` { usePolling: true } ` 。这是由于 Windows 文件系统的 [ WSL2 限制] ( https://github.com/microsoft/WSL/issues/4739 ) 造成的。
485
486
486
- Vite 服务器默认会忽略对 ` .git/ ` 和 ` node_modules/ ` 目录的监听。如果你需要对 ` node_moduels /` 内的包进行监听,你可以为 ` server.watch.ignored ` 赋值一个取反的 glob 模式,例如:
487
+ Vite 服务器默认会忽略对 ` .git/ ` 和 ` node_modules/ ` 目录的监听。如果你需要对 ` node_modules /` 内的包进行监听,你可以为 ` server.watch.ignored ` 赋值一个取反的 glob 模式,例如:
487
488
488
489
``` js
489
490
export default defineConfig ({
Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ Vue 用户应使用官方提供的 [@vitejs/plugin-vue-jsx](https://github.com/v
108
108
109
109
``` js
110
110
// vite.config.js
111
+ import { defineConfig } from ' vite'
112
+
111
113
export default defineConfig ({
112
114
esbuild: {
113
115
jsxFactory: ' h' ,
@@ -122,6 +124,8 @@ export default defineConfig({
122
124
123
125
``` js
124
126
// vite.config.js
127
+ import { defineConfig } from ' vite'
128
+
125
129
export default defineConfig ({
126
130
esbuild: {
127
131
jsxInject: ` import React from 'react'`
Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ Vite 意在提供开箱即用的配置,同时它的 [插件 API](./api-plugin)
20
20
21
21
- 默认的构建目标浏览器是能 [ 在 script 标签上支持原生 ESM] ( https://caniuse.com/es6-module ) 和 [ 原生 ESM 动态导入] ( https://caniuse.com/es6-module-dynamic-import ) 。传统浏览器可以通过官方插件 [ @vitejs/plugin-legacy ] ( https://github.com/vitejs/vite/tree/main/packages/plugin-legacy ) 支持 —— 查看 [ 构建生产版本] ( ./build ) 章节获取更多细节。
22
22
23
+ ## 在线试用 Vite {#trying-vite-online}
24
+
25
+ 你可以通过 [ StackBlitz] ( https://vite.new/ ) 在线试用 vite。它直接在浏览器中运行基于 Vite 的构建,因此它与本地开发几乎无差别,同时无需在你的机器上安装任何东西。你可以浏览 ` vite.new/{template} ` 来选择你要使用的框架。
26
+
27
+ 目前支持的模板预设如下:
28
+
29
+ | JavaScript | TypeScript |
30
+ | :---: | :---: |
31
+ | [ vanilla] ( https://vite.new/vanilla ) | [ vanilla-ts] ( https://vite.new/vanilla-ts ) |
32
+ | [ vue] ( https://vite.new/vue ) | [ vue-ts] ( https://vite.new/vue-ts ) |
33
+ | [ react] ( https://vite.new/react ) | [ react-ts] ( https://vite.new/react-ts ) |
34
+ | [ preact] ( https://vite.new/preact ) | [ preact-ts] ( https://vite.new/preact-ts ) |
35
+ | [ lit] ( https://vite.new/lit ) | [ lit-ts] ( https://vite.new/lit-ts ) |
36
+ | [ svelte] ( https://vite.new/svelte ) | [ svelte-ts] ( https://vite.new/svelte-ts ) |
37
+
23
38
## 搭建第一个 Vite 项目 {#scaffolding-your-first-vite-project}
24
39
25
40
::: tip 兼容性注意
@@ -41,7 +56,7 @@ $ yarn create vite
41
56
使用 PNPM:
42
57
43
58
``` bash
44
- $ pnpm dlx create- vite
59
+ $ pnpm create vite
45
60
```
46
61
47
62
然后按照提示操作即可!
@@ -57,24 +72,12 @@ npm init vite@latest my-vue-app -- --template vue
57
72
58
73
# yarn
59
74
yarn create vite my-vue-app --template vue
75
+
76
+ # pnpm
77
+ pnpm create vite my-vue-app -- --template vue
60
78
```
61
79
62
- 支持的模板预设包括:
63
-
64
- - ` vanilla `
65
- - ` vanilla-ts `
66
- - ` vue `
67
- - ` vue-ts `
68
- - ` react `
69
- - ` react-ts `
70
- - ` preact `
71
- - ` preact-ts `
72
- - ` lit `
73
- - ` lit-ts `
74
- - ` svelte `
75
- - ` svelte-ts `
76
-
77
- 查看 [ create-vite] ( https://github.com/vitejs/vite/tree/main/packages/create-vite ) 以获取每个模板的更多细节。
80
+ 查看 [ create-vite] ( https://github.com/vitejs/vite/tree/main/packages/create-vite ) 以获取每个模板的更多细节:` vanilla ` ,` vanilla-ts ` ,` vue ` ,` vue-ts ` ,` react ` ,` react-ts ` ,` preact ` ,` preact-ts ` ,` lit ` ,` lit-ts ` ,` svelte ` ,` svelte-ts ` 。
78
81
79
82
## 社区模板 {#community-templates}
80
83
You can’t perform that action at this time.
0 commit comments