Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Properties

cors?: boolean | CorsOptions

Configure CORS for the dev server. Uses https://github.com/expressjs/cors. Set to true to allow all methods from any origin, or configure separately using an object.

Options for files served via '/@fs/'.

headers?: OutgoingHttpHeaders

Specify server response headers.

hmr?: boolean | HmrOptions

Configure HMR-specific options (port, host, path & protocol)

host?: string | boolean

Specify which IP addresses the server should listen on. Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.

https?: ServerOptions<typeof IncomingMessage, typeof ServerResponse>

Enable TLS + HTTP/2. Note: this downgrades to TLS only when the proxy option is also used.

middlewareMode: boolean

Create Vite dev server to be used as a middleware in an existing server

open?: string | boolean

Open browser window on startup

origin?: string

Origin for the generated asset URLs.

example

http://127.0.0.1:8080

port?: number

Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on.

preTransformRequests?: boolean

Pre-transform known direct imports

default

true

proxy?: Record<string, string | ProxyOptions>

Configure custom proxy rules for the dev server. Expects an object of { key: options } pairs. Uses http-proxy. Full options here.

Example vite.config.js:

module.exports = {
proxy: {
// string shorthand
'/foo': 'http://localhost:4567/foo',
// with options
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
}
sourcemapIgnoreList: (sourcePath: string, sourcemapPath: string) => boolean

Whether or not to ignore-list source files in the dev server sourcemap, used to populate the x_google_ignoreList source map extension.

By default, it excludes all paths containing node_modules. You can pass false to disable this behavior, or, for full control, a function that takes the source path and sourcemap path and returns whether to ignore the source path.

Type declaration

    • (sourcePath: string, sourcemapPath: string): boolean
    • Parameters

      • sourcePath: string
      • sourcemapPath: string

      Returns boolean

strictPort?: boolean

If enabled, vite will exit if specified port is already in use

warmup?: { clientFiles?: string[]; ssrFiles?: string[] }

Warm-up files to transform and cache the results in advance. This improves the initial page load during server starts and prevents transform waterfalls.

Type declaration

  • Optional clientFiles?: string[]

    The files to be transformed and used on the client-side. Supports glob patterns.

  • Optional ssrFiles?: string[]

    The files to be transformed and used in SSR. Supports glob patterns.

watch?: null | WatchOptions

chokidar watch options or null to disable FS watching https://github.com/paulmillr/chokidar#api