Skip to content

Commit 5f43cae

Browse files
sync: Update Vite docs from upstream 20250624
1 parent aae563c commit 5f43cae

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

docs/guide/api-environment-plugins.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ The hook can choose to:
126126
}
127127
```
128128
129+
## Per-environment State in Plugins
130+
131+
Given that the same plugin instance is used for different environments, the plugin state needs to be keyed with `this.environment`. This is the same pattern the ecosystem has already been using to keep state about modules using the `ssr` boolean as key to avoid mixing client and ssr modules state. A `Map<Environment, State>` can be used to keep the state for each environment separately. Note that for backward compatibility, `buildStart` and `buildEnd` are only called for the client environment without the `perEnvironmentStartEndDuringDev: true` flag.
132+
133+
```js
134+
function PerEnvironmentCountTransformedModulesPlugin() {
135+
const state = new Map<Environment, { count: number }>()
136+
return {
137+
name: 'count-transformed-modules',
138+
perEnvironmentStartEndDuringDev: true,
139+
buildStart() {
140+
state.set(this.environment, { count: 0 })
141+
},
142+
transform(id) {
143+
state.get(this.environment).count++
144+
},
145+
buildEnd() {
146+
console.log(this.environment.name, state.get(this.environment).count)
147+
}
148+
}
149+
}
150+
```
151+
129152
## Per-environment Plugins
130153
131154
A plugin can define what are the environments it should apply to with the `applyToEnvironment` function.

docs/guide/api-plugin.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo
338338
Dedicated hook for transforming HTML entry point files such as `index.html`. The hook receives the current HTML string and a transform context. The context exposes the [`ViteDevServer`](./api-javascript#vitedevserver) instance during dev, and exposes the Rollup output bundle during build.
339339

340340
The hook can be async and can return one of the following:
341-
342341
- Transformed HTML string
343342
- An array of tag descriptor objects (`{ tag, attrs, children }`) to inject to the existing HTML. Each tag can also specify where it should be injected to (default is prepending to `<head>`)
344343
- An object containing both as `{ html, tags }`
@@ -417,13 +416,11 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo
417416
server: ViteDevServer
418417
}
419418
```
420-
421419
- `modules` is an array of modules that are affected by the changed file. It's an array because a single file may map to multiple served modules (e.g. Vue SFCs).
422420

423421
- `read` is an async read function that returns the content of the file. This is provided because on some systems, the file change callback may fire too fast before the editor finishes updating the file and direct `fs.readFile` will return empty content. The read function passed in normalizes this behavior.
424422

425423
The hook can choose to:
426-
427424
- Filter and narrow down the affected module list so that the HMR is more accurate.
428425

429426
- Return an empty array and perform a full reload:

docs/guide/backend-integration.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ If you need a custom integration, you can follow the steps in this guide to conf
4545
```
4646

4747
In order to properly serve assets, you have two options:
48-
4948
- Make sure the server is configured to proxy static assets requests to the Vite server
5049
- Set [`server.origin`](/config/server-options.md#server-origin) so that generated asset URLs will be resolved using the back-end server URL instead of a relative path
5150

@@ -100,7 +99,6 @@ If you need a custom integration, you can follow the steps in this guide to conf
10099
}
101100
}
102101
```
103-
104102
- The manifest has a `Record<name, chunk>` structure
105103
- For entry or dynamic entry chunks, the key is the relative src path from project root.
106104
- For non entry chunks, the key is the base name of the generated file prefixed with `_`.
@@ -131,7 +129,6 @@ If you need a custom integration, you can follow the steps in this guide to conf
131129

132130
Specifically, a backend generating HTML should include the following tags given a manifest
133131
file and an entry point:
134-
135132
- A `<link rel="stylesheet">` tag for each file in the entry point chunk's `css` list
136133
- Recursively follow all chunks in the entry point's `imports` list and include a
137134
`<link rel="stylesheet">` tag for each CSS file of each imported chunk.

docs/guide/static-deploy.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ You can deploy your Vite app as a Static Site on [Render](https://render.com/).
265265
3. Connect your GitHub/GitLab account or use a public repository.
266266

267267
4. Specify a project name and branch.
268-
269268
- **Build Command**: `npm install && npm run build`
270269
- **Publish Directory**: `dist`
271270

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"gsap": "^3.13.0",
1515
"vitepress": "^1.6.3",
1616
"vitepress-plugin-group-icons": "^1.6.0",
17-
"vitepress-plugin-llms": "^1.5.0",
18-
"vue": "^3.5.16"
17+
"vitepress-plugin-llms": "^1.5.1",
18+
"vue": "^3.5.17"
1919
}
2020
}

0 commit comments

Comments
 (0)