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
Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname. If you want to open the server in a specific browser you like, you can set the env `process.env.BROWSER` (e.g. `firefox`). See [the `open` package](https://github.com/sindresorhus/open#app) for more details.
Configure custom proxy rules for the dev server. Expects an object of `{ key: options }` pairs. If the key starts with `^`, it will be interpreted as a `RegExp`. The `configure` option can be used to access the proxy instance.
69
69
@@ -72,6 +72,6 @@ Uses [`http-proxy`](https://github.com/http-party/node-http-proxy). Full options
Configure CORS for the dev server. This is enabled by default and allows any origin. Pass an [options object](https://github.com/expressjs/cors) to fine tune the behavior or `false` to disable.
Copy file name to clipboardExpand all lines: docs/config/server-options.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ There are cases when other servers might respond instead of Vite.
16
16
17
17
The first case is when `localhost` is used. Node.js below v17 reorders the result of DNS-resolved address by default. When accessing `localhost`, browsers use DNS to resolve the address and that address might differ from the address which Vite is listening.
18
18
19
-
You could set [`dns.setDefaultResultOrder('verbatim')`](https://nodejs.org/docs/latest-v18.x/api/dns.html#dnssetdefaultresultorderorder) to disable the reordering behavior. Or you could set `server.host` to `127.0.0.1` explicitly.
19
+
You could set [`dns.setDefaultResultOrder('verbatim')`](https://nodejs.org/api/dns.html#dns_dns_setdefaultresultorder_order) to disable the reordering behavior. Or you could set `server.host` to `127.0.0.1` explicitly.
@@ -20,11 +20,11 @@ The behavior is similar to webpack's `file-loader`. The difference is that the i
20
20
21
21
- If using the Vue plugin, asset references in Vue SFC templates are automatically converted into imports.
22
22
23
-
- Common image, media, and font filetypes are detected as assets automatically. You can extend the internal list using the [`assetsInclude` option](/config/#assetsinclude).
23
+
- Common image, media, and font filetypes are detected as assets automatically. You can extend the internal list using the [`assetsInclude` option](/config/shared-options.md#assetsinclude).
24
24
25
25
- Referenced assets are included as part of the build assets graph, will get hashed file names, and can be processed by plugins for optimization.
26
26
27
-
- Assets smaller in bytes than the [`assetsInlineLimit` option](/config/#build-assetsinlinelimit) will be inlined as base64 data URLs.
27
+
- Assets smaller in bytes than the [`assetsInlineLimit` option](/config/build-options.md#build-assetsinlinelimit) will be inlined as base64 data URLs.
28
28
29
29
### Explicit URL Imports
30
30
@@ -76,7 +76,7 @@ If you have assets that are:
76
76
77
77
Then you can place the asset in a special `public` directory under your project root. Assets in this directory will be served at root path `/` during dev, and copied to the root of the dist directory as-is.
78
78
79
-
The directory defaults to `<root>/public`, but can be configured via the [`publicDir` option](/config/#publicdir).
79
+
The directory defaults to `<root>/public`, but can be configured via the [`publicDir` option](/config/shared-options.md#publicdir).
80
80
81
81
Note that:
82
82
@@ -115,5 +115,5 @@ This pattern does not work if you are using Vite for Server-Side Rendering, beca
115
115
:::
116
116
117
117
::: warning `target` needs to be `es2020` or higher
118
-
This pattern will not work if [build-target](https://vitejs.dev/config/#build-target) or [optimizedeps.esbuildoptions.target](https://vitejs.dev/config/#optimizedeps-esbuildoptions) is set to a value lower than `es2020`.
118
+
This pattern will not work if [build-target](/config/build-options.md#build-target) or [optimizedeps.esbuildoptions.target](/config/dep-optimization-options.md#optimizedeps-esbuildoptions) is set to a value lower than `es2020`.
Copy file name to clipboardExpand all lines: docs/guide/backend-integration.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ If you need a custom integration, you can follow the steps in this guide to conf
22
22
})
23
23
```
24
24
25
-
If you haven't disabled the [module preload polyfill](/config/#build-polyfillmodulepreload), you also need to import the polyfill in your entry
25
+
If you haven't disabled the [module preload polyfill](/config/build-options.md#build-polyfillmodulepreload), you also need to import the polyfill in your entry
26
26
27
27
```js
28
28
// add the beginning of your app entry
@@ -39,7 +39,7 @@ If you need a custom integration, you can follow the steps in this guide to conf
39
39
In order to properly serve assets, you have two options:
40
40
41
41
- Make sure the server is configured to proxy static assets requests to the Vite server
42
-
- Set [`server.origin`](https://vitejs.dev/config/#server-origin) so that generated asset URLs will be resolved using the back-end server URL instead of a relative path
42
+
- 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
43
43
44
44
This is needed for assets such as images to load properly.
Copy file name to clipboardExpand all lines: docs/guide/build.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ The production bundle assumes support for modern JavaScript. By default, Vite ta
11
11
- Safari >=13
12
12
- Edge >=88
13
13
14
-
You can specify custom targets via the [`build.target` config option](/config/#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`.
15
15
16
16
Note that by default, Vite only handles syntax transforms and **does not cover polyfills by default**. You can check out [Polyfill.io](https://polyfill.io/v3/) which is a service that automatically generates polyfill bundles based on the user's browser UserAgent string.
17
17
@@ -21,15 +21,15 @@ Legacy browsers can be supported via [@vitejs/plugin-legacy](https://github.com/
21
21
22
22
- Related: [Asset Handling](./assets)
23
23
24
-
If you are deploying your project under a nested public path, simply specify the [`base` config option](/config/#base) and all asset paths will be rewritten accordingly. This option can also be specified as a command line flag, e.g. `vite build --base=/my/public/path/`.
24
+
If you are deploying your project under a nested public path, simply specify the [`base` config option](/config/shared-options.md#base) and all asset paths will be rewritten accordingly. This option can also be specified as a command line flag, e.g. `vite build --base=/my/public/path/`.
25
25
26
26
JS-imported asset URLs, CSS `url()` references, and asset references in your `.html` files are all automatically adjusted to respect this option during build.
27
27
28
28
The exception is when you need to dynamically concatenate URLs on the fly. In this case, you can use the globally injected `import.meta.env.BASE_URL` variable which will be the public base path. Note this variable is statically replaced during build so it must appear exactly as-is (i.e. `import.meta.env['BASE_URL']` won't work).
29
29
30
30
## Customizing the Build
31
31
32
-
The build can be customized via various [build config options](/config/#build-options). Specifically, you can directly adjust the underlying [Rollup options](https://rollupjs.org/guide/en/#big-list-of-options) via `build.rollupOptions`:
32
+
The build can be customized via various [build config options](/config/build-options.md). Specifically, you can directly adjust the underlying [Rollup options](https://rollupjs.org/guide/en/#big-list-of-options) via `build.rollupOptions`:
33
33
34
34
```js
35
35
// vite.config.js
@@ -116,7 +116,7 @@ If you specify a different root, remember that `__dirname` will still be the fol
116
116
117
117
When you are developing a browser-oriented library, you are likely spending most of the time on a test/demo page that imports your actual library. With Vite, you can use your `index.html` for that purpose to get the smooth development experience.
118
118
119
-
When it is time to bundle your library for distribution, use the [`build.lib` config option](/config/#build-lib). Make sure to also externalize any dependencies that you do not want to bundle into your library, e.g. `vue` or `react`:
119
+
When it is time to bundle your library for distribution, use the [`build.lib` config option](/config/build-options.md#build-lib). Make sure to also externalize any dependencies that you do not want to bundle into your library, e.g. `vue` or `react`:
Copy file name to clipboardExpand all lines: docs/guide/dep-pre-bundling.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ After the server has already started, if a new dependency import is encountered
42
42
43
43
In a monorepo setup, a dependency may be a linked package from the same repo. Vite automatically detects dependencies that are not resolved from `node_modules` and treats the linked dep as source code. It will not attempt to bundle the linked dep, and will analyze the linked dep's dependency list instead.
44
44
45
-
However, this requires the linked dep to be exported as ESM. If not, you can add the dependency to [`optimizeDeps.include`](/config/#optimizedeps-include) and [`build.commonjsOptions.include`](/config/#build-commonjsoptions) in your config.
45
+
However, this requires the linked dep to be exported as ESM. If not, you can add the dependency to [`optimizeDeps.include`](/config/dep-optimization-options.md#optimizedeps-include) and [`build.commonjsOptions.include`](/config/build-options.md#build-commonjsoptions) in your config.
46
46
47
47
```js
48
48
exportdefaultdefineConfig({
@@ -65,7 +65,7 @@ Due to differences in linked dependency resolution, transitive dependencies can
65
65
66
66
## Customizing the Behavior
67
67
68
-
The default dependency discovery heuristics may not always be desirable. In cases where you want to explicitly include/exclude dependencies from the list, use the [`optimizeDeps` config options](/config/#dep-optimization-options).
68
+
The default dependency discovery heuristics may not always be desirable. In cases where you want to explicitly include/exclude dependencies from the list, use the [`optimizeDeps` config options](/config/dep-optimization-options.md).
69
69
70
70
A typical use case for `optimizeDeps.include` or `optimizeDeps.exclude` is when you have an import that is not directly discoverable in the source code. For example, maybe the import is created as a result of a plugin transform. This means Vite won't be able to discover the import on the initial scan - it can only discover it after the file is requested by the browser and transformed. This will cause the server to immediately re-bundle after server start.
Copy file name to clipboardExpand all lines: docs/guide/env-and-mode.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Vite exposes env variables on the special **`import.meta.env`** object. Some bui
6
6
7
7
-**`import.meta.env.MODE`**: {string} the [mode](#modes) the app is running in.
8
8
9
-
-**`import.meta.env.BASE_URL`**: {string} the base url the app is being served from. This is determined by the [`base` config option](/config/#base).
9
+
-**`import.meta.env.BASE_URL`**: {string} the base url the app is being served from. This is determined by the [`base` config option](/config/shared-options.md#base).
10
10
11
11
-**`import.meta.env.PROD`**: {boolean} whether the app is running in production.
12
12
@@ -24,7 +24,7 @@ It will also replace these strings appearing in JavaScript strings and Vue templ
24
24
25
25
## `.env` Files
26
26
27
-
Vite uses [dotenv](https://github.com/motdotla/dotenv) to load additional environment variables from the following files in your [environment directory](/config/#envdir):
27
+
Vite uses [dotenv](https://github.com/motdotla/dotenv) to load additional environment variables from the following files in your [environment directory](/config/shared-options.md#envdir):
Copy file name to clipboardExpand all lines: docs/guide/features.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ Vite provides first-class Vue support:
116
116
117
117
Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots.
118
118
119
-
If not using JSX with React or Vue, custom `jsxFactory` and `jsxFragment` can be configured using the [`esbuild` option](/config/#esbuild). For example for Preact:
119
+
If not using JSX with React or Vue, custom `jsxFactory` and `jsxFragment` can be configured using the [`esbuild` option](/config/shared-options.md#esbuild). For example for Preact:
120
120
121
121
```js
122
122
// vite.config.js
@@ -175,7 +175,7 @@ import classes from './example.module.css'
CSS modules behavior can be configured via the [`css.modules` option](/config/#css-modules).
178
+
CSS modules behavior can be configured via the [`css.modules` option](/config/shared-options.md#css-modules).
179
179
180
180
If `css.modules.localsConvention` is set to enable camelCase locals (e.g. `localsConvention: 'camelCaseOnly'`), you can also use named imports:
181
181
@@ -428,7 +428,7 @@ const modules = {
428
428
Note that:
429
429
430
430
- This is a Vite-only feature and is not a web or ES standard.
431
-
- 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/#resolve-alias)).
431
+
- 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)).
432
432
- The glob matching is done via [`fast-glob`](https://github.com/mrmlnc/fast-glob) - check out its documentation for [supported glob patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax).
433
433
- 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.
434
434
@@ -517,7 +517,7 @@ If you wish to retrieve the worker as a URL, add the `url` query:
517
517
importMyWorkerfrom'./worker?worker&url'
518
518
```
519
519
520
-
See [Worker Options](/config/#worker-options) for details on configuring the bundling of all workers.
520
+
See [Worker Options](/config/worker-options.md) for details on configuring the bundling of all workers.
521
521
522
522
## Build Optimizations
523
523
@@ -527,7 +527,7 @@ See [Worker Options](/config/#worker-options) for details on configuring the bun
527
527
528
528
Vite automatically extracts the CSS used by modules in an async chunk and generates a separate file for it. The CSS file is automatically loaded via a `<link>` tag when the associated async chunk is loaded, and the async chunk is guaranteed to only be evaluated after the CSS is loaded to avoid [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content#:~:text=A%20flash%20of%20unstyled%20content,before%20all%20information%20is%20retrieved.).
529
529
530
-
If you'd rather have all the CSS extracted into a single file, you can disable CSS code splitting by setting [`build.cssCodeSplit`](/config/#build-csscodesplit) to `false`.
530
+
If you'd rather have all the CSS extracted into a single file, you can disable CSS code splitting by setting [`build.cssCodeSplit`](/config/build-options.md#build-csscodesplit) to `false`.
Copy file name to clipboardExpand all lines: docs/guide/migration.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -19,13 +19,13 @@ A small fraction of users will now require using [@vitejs/plugin-legacy](https:/
19
19
20
20
- The following options that were already deprecated in v2 have been removed:
21
21
22
-
-`alias` (switch to [`resolve.alias`](../config/shared-options.md#resolvealias))
23
-
-`dedupe` (switch to [`resolve.dedupe`](../config/shared-options.md#resolvededupe))
22
+
-`alias` (switch to [`resolve.alias`](../config/shared-options.md#resolve-alias))
23
+
-`dedupe` (switch to [`resolve.dedupe`](../config/shared-options.md#resolve-dedupe))
24
24
-`build.base` (switch to [`base`](../config/shared-options.md#base))
25
25
-`build.brotliSize` (switch to [`build.reportCompressedSize`](../config/build-options.md#build-reportcompressedsize))
26
26
-`build.cleanCssOptions` (Vite now uses esbuild for CSS minification)
27
27
-`build.polyfillDynamicImport` (use [`@vitejs/plugin-legacy`](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) for browsers without dynamic import support)
28
-
-`optimizeDeps.keepNames` (switch to [`optimizeDeps.esbuildOptions.keepNames`](../config/dep-optimization-options.md#optimizedepsesbuildoptions))
28
+
-`optimizeDeps.keepNames` (switch to [`optimizeDeps.esbuildOptions.keepNames`](../config/dep-optimization-options.md#optimizedeps-esbuildoptions))
29
29
30
30
## Achitecture changes and legacy Options
31
31
@@ -58,7 +58,7 @@ If you need to get back to the v2 strategy, you can use `legacy.buildRollupPlugi
58
58
59
59
### SSR Changes
60
60
61
-
Vite v3 uses ESM for the SSR build by default. When using ESM, the [SSR externalization heuristics](https://vitejs.dev/guide/ssr.html#ssr-externals) are no longer needed. By default, all dependencies are externalized. You can use [`ssr.noExternal`](../config/ssr-options.md#ssrnoexternal) to control what dependencies to include in the SSR bundle.
61
+
Vite v3 uses ESM for the SSR build by default. When using ESM, the [SSR externalization heuristics](https://vitejs.dev/guide/ssr.html#ssr-externals) are no longer needed. By default, all dependencies are externalized. You can use [`ssr.noExternal`](../config/ssr-options.md#ssr-noexternal) to control what dependencies to include in the SSR bundle.
62
62
63
63
If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics` to generate a CJS bundle using the same externalization strategy of Vite v2.
Copy file name to clipboardExpand all lines: docs/guide/static-deploy.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The following guides are based on some shared assumptions:
4
4
5
-
- You are using the default build output location (`dist`). This location [can be changed using `build.outDir`](https://vitejs.dev/config/#build-outdir), and you can extrapolate instructions from these guides in that case.
5
+
- You are using the default build output location (`dist`). This location [can be changed using `build.outDir`](/config/build-options.md#build-outdir), and you can extrapolate instructions from these guides in that case.
6
6
- You are using npm. You can use equivalent commands to run the scripts if you are using Yarn or other package managers.
7
7
- Vite is installed as a local dev dependency in your project, and you have setup the following npm scripts:
0 commit comments