File tree Expand file tree Collapse file tree 3 files changed +26
-18
lines changed
Expand file tree Collapse file tree 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 }) => {
376376### server.port {#server-port}
377377
378378- ** 类型:** ` number `
379+ - ** 默认值:** ` 3000 `
379380
380381 指定开发服务器端口。注意:如果端口已经被使用,Vite 会自动尝试下一个可用的端口,所以这可能不是开发服务器最终监听的实际端口。
381382
@@ -483,7 +484,7 @@ export default defineConfig(async ({ command, mode }) => {
483484
484485 当需要再 Windows Subsystem for Linux (WSL) 2 上运行 Vite 时,如果项目文件夹位于 Windows 文件系统中,你需要将此选项设置为 ` { usePolling: true } ` 。这是由于 Windows 文件系统的 [ WSL2 限制] ( https://github.com/microsoft/WSL/issues/4739 ) 造成的。
485486
486- Vite 服务器默认会忽略对 ` .git/ ` 和 ` node_modules/ ` 目录的监听。如果你需要对 ` node_moduels /` 内的包进行监听,你可以为 ` server.watch.ignored ` 赋值一个取反的 glob 模式,例如:
487+ Vite 服务器默认会忽略对 ` .git/ ` 和 ` node_modules/ ` 目录的监听。如果你需要对 ` node_modules /` 内的包进行监听,你可以为 ` server.watch.ignored ` 赋值一个取反的 glob 模式,例如:
487488
488489 ``` js
489490 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
108108
109109``` js
110110// vite.config.js
111+ import { defineConfig } from ' vite'
112+
111113export default defineConfig ({
112114 esbuild: {
113115 jsxFactory: ' h' ,
@@ -122,6 +124,8 @@ export default defineConfig({
122124
123125``` js
124126// vite.config.js
127+ import { defineConfig } from ' vite'
128+
125129export default defineConfig ({
126130 esbuild: {
127131 jsxInject: ` import React from 'react'`
Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ Vite 意在提供开箱即用的配置,同时它的 [插件 API](./api-plugin)
2020
2121- 默认的构建目标浏览器是能 [ 在 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 ) 章节获取更多细节。
2222
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+
2338## 搭建第一个 Vite 项目 {#scaffolding-your-first-vite-project}
2439
2540::: tip 兼容性注意
@@ -41,7 +56,7 @@ $ yarn create vite
4156使用 PNPM:
4257
4358``` bash
44- $ pnpm dlx create- vite
59+ $ pnpm create vite
4560```
4661
4762然后按照提示操作即可!
@@ -57,24 +72,12 @@ npm init vite@latest my-vue-app -- --template vue
5772
5873# yarn
5974yarn create vite my-vue-app --template vue
75+
76+ # pnpm
77+ pnpm create vite my-vue-app -- --template vue
6078```
6179
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 ` 。
7881
7982## 社区模板 {#community-templates}
8083
You can’t perform that action at this time.
0 commit comments