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
When set to `true`, the build will generate a `.vite/license.md` file that includes all bundled dependencies' licenses. It can be hosted to display and acknowledge the dependencies used by the app. When `fileName` is passed, it will be used as the license file name relative to the `outDir`. An example output may look like this:
194
+
195
+
```md
196
+
# Licenses
197
+
198
+
The app bundles dependencies which contain the following licenses:
199
+
200
+
## dep-1 - 1.2.3 (CC0-1.0)
201
+
202
+
CC0 1.0 Universal
203
+
204
+
...
205
+
206
+
## dep-2 - 4.5.6 (MIT)
207
+
208
+
MIT License
209
+
210
+
...
211
+
```
212
+
213
+
If the `fileName` ends with `.json`, the raw JSON metadata will be generated instead and can be used for further processing. For example:
214
+
215
+
```json
216
+
[
217
+
{
218
+
"name": "dep-1",
219
+
"version": "1.2.3",
220
+
"identifier": "CC0-1.0",
221
+
"text": "CC0 1.0 Universal\n\n..."
222
+
},
223
+
{
224
+
"name": "dep-2",
225
+
"version": "4.5.6",
226
+
"identifier": "MIT",
227
+
"text": "MIT License\n\n..."
228
+
}
229
+
]
230
+
```
231
+
232
+
::: tip
233
+
If you'd like to reference the license file in the built code, you can use `build.rollupOptions.output.banner` to inject a comment at the top of the files. For example:
234
+
235
+
```js twoslash [vite.config.js]
236
+
import { defineConfig } from'vite'
237
+
238
+
exportdefaultdefineConfig({
239
+
build: {
240
+
license:true,
241
+
rollupOptions: {
242
+
output: {
243
+
banner:
244
+
'/* See licenses of bundled dependencies at https://example.com/license.md */',
Copy file name to clipboardExpand all lines: docs/config/dep-optimization-options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Unless noted, the options in this section are only applied to the dependency opt
10
10
11
11
By default, Vite will crawl all your `.html` files to detect dependencies that need to be pre-bundled (ignoring `node_modules`, `build.outDir`, `__tests__` and `coverage`). If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead.
12
12
13
-
If neither of these fit your needs, you can specify custom entries using this option - the value should be a [`tinyglobby` pattern](https://github.com/SuperchupuDev/tinyglobby) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitly defined. If other folders need to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`. `node_modules` will not be ignored for patterns that explicitly include the string `node_modules`.
13
+
If neither of these fit your needs, you can specify custom entries using this option - the value should be a [`tinyglobby` pattern](https://superchupu.dev/tinyglobby/comparison) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitly defined. If other folders need to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`. `node_modules` will not be ignored for patterns that explicitly include the string `node_modules`.
Copy file name to clipboardExpand all lines: docs/config/server-options.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,8 +92,6 @@ Set to `true` to exit if port is already in use, instead of automatically trying
92
92
93
93
Enable TLS + HTTP/2. The value is an [options object](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener) passed to `https.createServer()`.
94
94
95
-
Note that this downgrades to TLS only when the [`server.proxy` option](#server-proxy) is also used.
96
-
97
95
A valid certificate is needed. For a basic setup, you can add [@vitejs/plugin-basic-ssl](https://github.com/vitejs/vite-plugin-basic-ssl) to the project plugins, which will automatically create and cache a self-signed certificate. But we recommend creating your own certificates.
98
96
99
97
## server.open
@@ -233,7 +231,7 @@ The error that appears in the Browser when the fallback happens can be ignored.
233
231
234
232
Warm up files to transform and cache the results in advance. This improves the initial page load during server starts and prevents transform waterfalls.
235
233
236
-
`clientFiles` are files that are used in the client only, while `ssrFiles` are files that are used in SSR only. They accept an array of file paths or [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby) patterns relative to the `root`.
234
+
`clientFiles` are files that are used in the client only, while `ssrFiles` are files that are used in SSR only. They accept an array of file paths or [`tinyglobby` patterns](https://superchupu.dev/tinyglobby/comparison) relative to the `root`.
237
235
238
236
Make sure to only add files that are frequently used to not overload the Vite dev server on startup.
Copy file name to clipboardExpand all lines: docs/guide/api-environment-plugins.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ The hook can choose to:
146
146
147
147
## Per-environment State in Plugins
148
148
149
-
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.
149
+
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. Same for `watchChange` and the `perEnvironmentWatchChangeDuringDev:true` flag.
The `applyToEnvironment` hook is called at config time, currently after `configResolved` due to projects in the ecosystem modifying the plugins in it. Environment plugins resolution may be moved before `configResolved` in the future.
229
229
230
+
## Application-Plugin Communication
231
+
232
+
`environment.hot` allows plugins to communicate with the code on the application side for a given environment. This is the equivalent of [the Client-server Communication feature](/guide/api-plugin#client-server-communication), but supports environments other than the client environment.
233
+
234
+
:::warning Note
235
+
236
+
Note that this feature is only available for environments that supports HMR.
237
+
238
+
:::
239
+
240
+
### Managing the Application Instances
241
+
242
+
Be aware that there might be multiple application instances running in the same environment. For example, if you multiple tabs open in the browser, each tab is a separate application instance and have a separate connection to the server.
243
+
244
+
When a new connection is established, a `vite:client:connect` event is emitted on the environment's `hot` instance. When the connection is closed, a `vite:client:disconnect` event is emitted.
245
+
246
+
Each event handler receives the `NormalizedHotChannelClient` as the second argument. The client is an object with a `send` method that can be used to send messages to that specific application instance. The client reference is always the same for the same connection, so you can keep it to track the connection.
Make sure to implement the `vite:client:connect` / `vite:client:disconnect` events in the `on` / `off` methods when those methods exist. `vite:client:connect` event should be emitted when the connection is established, and `vite:client:disconnect` event should be emitted when the connection is closed. The `HotChannelClient` object passed to the event handler must have the same reference for the same connection.
385
+
366
386
A different example using an HTTP request to communicate between the runner and the server:
Copy file name to clipboardExpand all lines: docs/guide/features.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -619,7 +619,7 @@ Note that:
619
619
620
620
- This is a Vite-only feature and is not a web or ES standard.
621
621
- The glob patterns are treated like import specifiers: they must be either relative (start with `./`) or absolute (start with `/`, resolved relative to project root) or an alias path (see [`resolve.alias` option](/config/shared-options.md#resolve-alias)).
622
-
- The glob matching is done via [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby).
622
+
- The glob matching is done via [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby) - check out its documentation for [supported glob patterns](https://superchupu.dev/tinyglobby/comparison).
623
623
- You should also be aware that all the arguments in the `import.meta.glob` must be **passed as literals**. You can NOT use variables or expressions in them.
Copy file name to clipboardExpand all lines: docs/guide/rolldown.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -345,4 +345,4 @@ const plugin = {
345
345
}
346
346
```
347
347
348
-
This is because [Rolldown supports non-JavaScript modules](https://rolldown.rs/guide/in-depth/module-types) and infers the module type from extensions unless specified.
348
+
This is because [Rolldown supports non-JavaScript modules](https://rolldown.rs/in-depth/module-types) and infers the module type from extensions unless specified.
Copy file name to clipboardExpand all lines: docs/guide/static-deploy.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Now the `preview` command will launch the server at `http://localhost:8080`.
63
63
64
64
2. Go to your GitHub Pages configuration in the repository settings page and choose the source of deployment as "GitHub Actions", this will lead you to create a workflow that builds and deploys your project, a sample workflow that installs dependencies and builds using npm is provided:
0 commit comments