Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guide/api-environment-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const server = createServer()
const ssrEnvironment = server.environment.ssr
const input = {}

const { createHandler } = await ssrEnvironment.runner.import('./entry.js')
const { createHandler } = await ssrEnvironment.runner.import('./entrypoint.js')
const handler = createHandler(input)
const response = handler(new Request('/'))

Expand Down
4 changes: 4 additions & 0 deletions guide/env-and-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

Vite 在特殊的 `import.meta.env` 对象下暴露了一些常量。这些常量在开发阶段被定义为全局变量,并在构建阶段被静态替换,以使树摇(tree-shaking)更有效。

<<<<<<< HEAD
## 内置常量 {#built-in-constants}
=======
## Built-in Constants
>>>>>>> 47e88f5402396bf3ae637316f2ab1a0bc81e5549

一些内置常量在所有情况下都可用:

Expand Down
16 changes: 16 additions & 0 deletions guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ $ pnpm create vite
$ bun create vite
```

```bash [Deno]
$ deno init --npm vite
```

:::

然后按照提示操作即可!
Expand All @@ -90,6 +94,10 @@ $ pnpm create vite my-vue-app --template vue
$ bun create vite my-vue-app --template vue
```

```bash [Deno]
$ deno init --npm vite my-vue-app --template vue
```

:::

查看 [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) 以获取每个模板的更多细节:`vanilla`,`vanilla-ts`,`vue`,`vue-ts`,`react`,`react-ts`,`react-swc`,`react-swc-ts`,`preact`,`preact-ts`,`lit`,`lit-ts`,`svelte`,`svelte-ts`,`solid`,`solid-ts`,`qwik`,`qwik-ts`。
Expand Down Expand Up @@ -134,6 +142,10 @@ $ pnpm add -D vite
$ bun add -D vite
```

```bash [Deno]
$ deno add -D npm:vite
```

:::

并创建一个像这样的 `index.html` 文件:
Expand Down Expand Up @@ -162,6 +174,10 @@ $ pnpm vite
$ bunx vite
```

```bash [Deno]
$ deno run -A npm:vite
```

:::

之后就可以在 `http://localhost:5173` 上访问 `index.html`。
Expand Down
11 changes: 10 additions & 1 deletion guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ if (import.meta.env.SSR) {

## 设置开发服务器 {#setting-up-the-dev-server}

<<<<<<< HEAD
在构建 SSR 应用程序时,你可能希望完全控制主服务器,并将 Vite 与生产环境脱钩。因此,建议以中间件模式使用 Vite。下面是一个关于 [express](https://expressjs.com/) (v4) 的例子:
=======
When building an SSR app, you likely want to have full control over your main server and decouple Vite from the production environment. It is therefore recommended to use Vite in middleware mode. Here is an example with [express](https://expressjs.com/):
>>>>>>> 47e88f5402396bf3ae637316f2ab1a0bc81e5549

```js{15-18} twoslash [server.js]
import fs from 'node:fs'
Expand Down Expand Up @@ -93,8 +97,13 @@ async function createServer() {
// 即使在重新启动后,以下内容仍然有效。
app.use(vite.middlewares)

<<<<<<< HEAD
app.use('*', async (req, res) => {
// 服务 index.html - 下面我们来处理这个问题
=======
app.use('*all', async (req, res) => {
// serve index.html - we will tackle this next
>>>>>>> 47e88f5402396bf3ae637316f2ab1a0bc81e5549
})

app.listen(5173)
Expand All @@ -119,7 +128,7 @@ var app
var vite

// ---cut---
app.use('*', async (req, res, next) => {
app.use('*all', async (req, res, next) => {
const url = req.originalUrl

try {
Expand Down
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
<<<<<<< HEAD
"name": "vite-docs-cn",
"version": "1.0.0",
"description": "Vite.js documentation Chinese translation.",
Expand Down Expand Up @@ -33,4 +34,23 @@
"gitHooks": {
"commit-msg": "node scripts/verifyCommit.js"
}
=======
"name": "docs",
"private": true,
"type": "module",
"scripts": {
"docs": "vitepress dev",
"docs-build": "vitepress build",
"docs-serve": "vitepress serve"
},
"devDependencies": {
"@shikijs/vitepress-twoslash": "^2.5.0",
"@types/express": "^5.0.1",
"feed": "^4.2.2",
"vitepress": "^1.6.3",
"vitepress-plugin-group-icons": "^1.5.2",
"vitepress-plugin-llms": "^1.1.0",
"vue": "^3.5.13"
}
>>>>>>> 47e88f5402396bf3ae637316f2ab1a0bc81e5549
}