Optional corsConfigure 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.
Optional headersSpecify server response headers.
Optional hmrConfigure HMR-specific options (port, host, path & protocol)
Optional hostSpecify which IP addresses the server should listen on. Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
Optional httpsEnable TLS + HTTP/2. Note: this downgrades to TLS only when the proxy option is also used.
Optional openOpen browser window on startup
Optional originOrigin for the generated asset URLs.
`http://127.0.0.1:8080`
Optional portSpecify 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.
Optional prePre-transform known direct imports
true
Optional proxyConfigure 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
'/foo': 'http://localhost:4567',
// with options
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: path => path.replace(/^/api/, '')
}
}
}
Optional strictIf enabled, vite will exit if specified port is already in use
Optional warmupWarm-up files to transform and cache the results in advance. This improves the initial page load during server starts and prevents transform waterfalls.
Optional clientThe files to be transformed and used on the client-side. Supports glob patterns.
Optional ssrThe files to be transformed and used in SSR. Supports glob patterns.
Optional watchchokidar watch options or null to disable FS watching https://github.com/paulmillr/chokidar#api
Construct a type with the properties of T except for those in type K.