build.target
- Type:
string | string[] - Default:
'baseline-widely-available' - Related: Browser Compatibility
'baseline-widely-available', which targets browsers that are included in the Baseline Widely Available on 2026-01-01. Specifically, it is ['chrome111', 'edge111', 'firefox114', 'safari16.4'].
Another special value is 'esnext' - which assumes native dynamic imports support and will only perform minimal transpiling.
The transform is performed with Oxc Transformer and the value should be a valid Oxc Transformer target option. Custom targets can either be an ES version (e.g. es2015), a browser with version (e.g. chrome58), or an array of multiple target strings.
Note the build will output a warning if the code contains features that cannot be safely transpiled by Oxc. See Oxc docs for more details.
build.modulePreload
- Type:
boolean | { polyfill?: boolean, resolveDependencies?: ResolveModulePreloadDependenciesFn } - Default:
{ polyfill: true }
index.html entry. If the build is configured to use a non-HTML custom entry via build.rollupOptions.input, then it is necessary to manually import the polyfill in your custom entry:
The polyfill does not apply to Library Mode. If you need to support browsers without native dynamic import, you should probably avoid using it in your library.
{ polyfill: false }.
The list of chunks to preload for each dynamic import is computed by Vite. By default, an absolute path including the base will be used when loading these dependencies. If the base is relative ('' or './'), import.meta.url is used at runtime to avoid absolute paths that depend on the final deployed base.
There is experimental support for fine grained control over the dependencies list and their paths using the resolveDependencies function. Give Feedback. It expects a function of type ResolveModulePreloadDependenciesFn:
resolveDependencies function will be called for each dynamic import with a list of the chunks it depends on, and it will also be called for each chunk imported in entry HTML files. A new dependencies array can be returned with these filtered or more dependencies injected, and their paths modified. The deps paths are relative to the build.outDir. The return value should be a relative path to the build.outDir.
experimental.renderBuiltUrl.
build.polyfillModulePreload
- Type:
boolean - Default:
true - Deprecated use
build.modulePreload.polyfillinstead
build.outDir
- Type:
string - Default:
dist
build.assetsDir
- Type:
string - Default:
assets
build.outDir. This is not used in Library Mode).
build.assetsInlineLimit
- Type:
number|((filePath: string, content: Buffer) => boolean | undefined) - Default:
4096(4 KiB)
0 to disable inlining altogether.
If a callback is passed, a boolean can be returned to opt-in or opt-out. If nothing is returned the default logic applies.
Git LFS placeholders are automatically excluded from inlining because they do not contain the content of the file they represent.
build.cssCodeSplit
- Type:
boolean - Default:
true
build.cssTarget
- Type:
string | string[] - Default: the same as
build.target
#RGBA hexadecimal color notation in CSS.
In this case, you need to set build.cssTarget to chrome61 to prevent vite from transforming rgba() colors into #RGBA hexadecimal notations.
build.cssMinify
- Type:
boolean | 'lightningcss' | 'esbuild' - Default: the same as
build.minifyfor client,'lightningcss'for SSR
build.minify, so you can configure minification for JS and CSS separately. Vite uses Lightning CSS by default to minify CSS. It can be configured using css.lightningcss. Set the option to 'esbuild' to use esbuild instead.
esbuild must be installed when it is set to 'esbuild'.
build.sourcemap
- Type:
boolean | 'inline' | 'hidden' - Default:
false
true, a separate sourcemap file will be created. If 'inline', the sourcemap will be appended to the resulting output file as a data URI. 'hidden' works like true except that the corresponding sourcemap comments in the bundled files are suppressed.
build.rolldownOptions
- Type:
RolldownOptions
build.rollupOptions
- Type:
RolldownOptions - Deprecated
build.rolldownOptions option. Use build.rolldownOptions option instead.
build.dynamicImportVarsOptions
- Type:
{ include?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[] } - Related: Dynamic Import
build.lib
- Type:
{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string), cssFileName?: string } - Related: Library Mode
entry is required since the library cannot use HTML as entry. name is the exposed global variable and is required when formats includes 'umd' or 'iife'. Default formats are ['es', 'umd'], or ['es', 'cjs'], if multiple entries are used.
fileName is the name of the package file output, which defaults to the "name" in package.json. It can also be defined as a function taking the format and entryName as arguments, and returning the file name.
If your package imports CSS, cssFileName can be used to specify the name of the CSS file output. It defaults to the same value as fileName if it’s set a string, otherwise it also falls back to the "name" in package.json.
vite.config.js
build.license
- Type:
boolean | { fileName?: string } - Default:
false - Related: License
true, the build will generate a .vite/license.md file that includes all bundled dependencies’ licenses.
If fileName is passed, it will be used as the license file name relative to the outDir. If it ends with .json, the raw JSON metadata will be generated instead and can be used for further processing. For example:
build.manifest
- Type:
boolean | string - Default:
false - Related: Backend Integration
build.outDir. When set to true, the path would be .vite/manifest.json.
If you are writing a plugin and need to inspect each output chunk or asset’s related CSS and static assets during the build, you can also use viteMetadata output bundle metadata API.
build.ssrManifest
- Type:
boolean | string - Default:
false - Related: Server-Side Rendering
build.outDir. When set to true, the path would be .vite/ssr-manifest.json.
build.ssr
- Type:
boolean | string - Default:
false - Related: Server-Side Rendering
true, which requires specifying the SSR entry via rollupOptions.input.
build.emitAssets
- Type:
boolean - Default:
false
build.ssrEmitAssets
- Type:
boolean - Default:
false
build.emitAssets once Environment API is stable.
build.minify
- Type:
boolean | 'oxc' | 'terser' | 'esbuild' - Default:
'oxc'for client build,falsefor SSR build
false to disable minification, or specify the minifier to use. The default is Oxc Minifier which is 30 ~ 90x faster than terser and only 0.5 ~ 2% worse compression. Benchmarks
build.minify: 'esbuild' is deprecated and will be removed in the future.
Note the build.minify option does not minify whitespaces when using the 'es' format in lib mode, as it removes pure annotations and breaks tree-shaking.
esbuild or Terser must be installed when it is set to 'esbuild' or 'terser' respectively.
build.terserOptions
- Type:
TerserOptions
maxWorkers: number option to specify the max number of workers to spawn. Defaults to the number of CPUs minus 1.
build.write
- Type:
boolean - Default:
true
false to disable writing the bundle to disk. This is mostly used in programmatic build() calls where further post processing of the bundle is needed before writing to disk.
build.emptyOutDir
- Type:
boolean - Default:
trueifoutDiris insideroot
outDir on build if it is inside project root. It will emit a warning if outDir is outside of root to avoid accidentally removing important files. You can explicitly set this option to suppress the warning. This is also available via command line as --emptyOutDir.
build.copyPublicDir
- Type:
boolean - Default:
true
publicDir into the outDir on build. Set to false to disable this.
build.reportCompressedSize
- Type:
boolean - Default:
true
build.chunkSizeWarningLimit
- Type:
number - Default:
500
build.watch
- Type:
WatcherOptions| null - Default:
null
{} to enable rollup watcher. This is mostly used in cases that involve build-only plugins or integrations processes.