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
Copy file name to clipboardExpand all lines: docs/config/index.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,10 @@ You can also explicitly specify a config file to use with the `--config` CLI opt
22
22
vite --config my-config.js
23
23
```
24
24
25
+
::: tip BUNDLING THE CONFIG
26
+
By default, Vite uses `esbuild` to bundle the config into a temporary file. This can cause issues when importing TypeScript files in a monorepo. If you encounter any issues with this approach, you can specify `--configLoader=runner` to use the module runner instead - it will not create a temporary config and will transform any files on the fly. Note that module runner doesn't support CJS in config files, but external CJS packages should work as usual.
27
+
:::
28
+
25
29
## Config Intellisense
26
30
27
31
Since Vite ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:
Configure CORS for the preview server. This is enabled by default and allows any origin. Pass an [options object](https://github.com/expressjs/cors#configuration-options) to fine tune the behavior or `false` to disable.
90
+
Configure CORS for the preview server.
91
+
92
+
See [`server.cors`](./server-options#server-cors) for more details.
Copy file name to clipboardExpand all lines: docs/config/server-options.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,20 @@ See [the WSL document](https://learn.microsoft.com/en-us/windows/wsl/networking#
42
42
43
43
:::
44
44
45
+
## server.allowedHosts
46
+
47
+
-**Type:**`string[] | true`
48
+
-**Default:**`[]`
49
+
50
+
The hostnames that Vite is allowed to respond to.
51
+
`localhost` and domains under `.localhost` and all IP addresses are allowed by default.
52
+
When using HTTPS, this check is skipped.
53
+
54
+
If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname. For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
55
+
56
+
If set to `true`, the server is allowed to respond to requests for any hosts.
57
+
This is not recommended as it will be vulnerable to DNS rebinding attacks.
-**Default:**`{ origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/ }` (allows localhost, `127.0.0.1` and `::1`)
150
165
151
-
Configure CORS for the dev server. This is enabled by default and allows any origin. Pass an [options object](https://github.com/expressjs/cors#configuration-options) to fine tune the behavior or `false` to disable.
166
+
Configure CORS for the dev server. Pass an [options object](https://github.com/expressjs/cors#configuration-options) to fine tune the behavior or `true` to allow any origin.
167
+
168
+
:::warning
169
+
170
+
We recommend setting a specific value rather than `true` to avoid exposing the source code to untrusted origins.
Copy file name to clipboardExpand all lines: docs/guide/api-environment-frameworks.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,8 +46,13 @@ The `runner` is evaluated eagerly when it's accessed for the first time. Beware
46
46
Given a Vite server configured in middleware mode as described by the [SSR setup guide](/guide/ssr#setting-up-the-dev-server), let's implement the SSR middleware using the environment API. Error handling is omitted.
Copy file name to clipboardExpand all lines: docs/guide/build.md
+19-5Lines changed: 19 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,19 @@ When it is time to deploy your app for production, simply run the `vite build` c
4
4
5
5
## Browser Compatibility
6
6
7
-
The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the [native ES Modules](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta):
7
+
By default, the production bundle assumes support for modern JavaScript, including [native ES Modules](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta). The default browser support range is:
8
8
9
9
- Chrome >=87
10
10
- Firefox >=78
11
11
- Safari >=14
12
12
- Edge >=88
13
13
14
-
You can specify custom targets via the [`build.target` config option](/config/build-options.md#build-target), where the lowest target is `es2015`.
14
+
You can specify custom targets via the [`build.target` config option](/config/build-options.md#build-target), where the lowest target is `es2015`. If a lower target is set, Vite will still require these minimum browser support ranges as it relies on [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import) and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta):
15
+
16
+
- Chrome >=64
17
+
- Firefox >=67
18
+
- Safari >=11.1
19
+
- Edge >=79
15
20
16
21
Note that by default, Vite only handles syntax transforms and **does not cover polyfills**. You can check out https://cdnjs.cloudflare.com/polyfill/ which automatically generates polyfill bundles based on the user's browser UserAgent string.
17
22
@@ -106,9 +111,12 @@ During dev, simply navigate or link to `/nested/` - it works as expected, just l
106
111
During build, all you need to do is to specify multiple `.html` files as entry points:
0 commit comments