ViteConfig¶
interface ViteConfig
The main configuration block, exposed by the vite extension:
Properties¶
autoRewriteIndex¶
@get:
Internal
abstract val autoRewriteIndex: Property<Boolean>
Whether to rewrite <script> declaration in the index.html file to be compatible with the Vite plugin and Hot Module Replacement. Disabled by default.
Example¶
base¶
Base public path when served in development or production.
Valid values include:
-
Absolute URL pathname, e.g.
/foo/, -
Full URL, e.g.
https://foo.com/, -
Empty string or
./(for embedded deployment).
Example¶
To expose the generate website to the /ui path instead of the website root, use:
External resources¶
build¶
open fun build(block: ViteBuildConfig.() -> Unit): ViteBuildConfig
abstract val build: ViteBuildConfig
cacheDir¶
Directory to save cache files. Files in this directory are pre-bundled deps or some other cache files generated by vite, which can improve the performance.
The value can be either an absolute file system path or a path relative to project root.
plugins¶
@get:
Internal
abstract val plugins: ListProperty<ExternalVitePlugin>
The list of Vite plugins from NPM imported by this project.
To easily add values of this property, we provide the plugin helper function.
For more information on plugins, see ExternalVitePlugin.
publicDir¶
Directory to serve as plain static assets. Files in this directory are served at / during dev and copied to the root outDir during build, and are always served or copied as-is without transform.
The value can be either an absolute file system path or a path relative to the project root.
root¶
@get:
Internal
abstract val root: DirectoryProperty
server¶
open fun server(block: ViteServerConfig.() -> Unit): ViteServerConfig
abstract val server: ViteServerConfig
version¶
Functions¶
localPlugin¶
Imports a local file as a Vite plugin.
Local plugins are not added to package.json and are not downloaded. For more information, see ExternalVitePlugin.isLocal.
This is a helper function to add an element to plugins. For more information on the different parameters, see ExternalVitePlugin.
Example¶
plugin¶
Imports a plugin from NPM.
This is a helper function to add an element to plugins. For more information on the different parameters, see ExternalVitePlugin.
Example¶
setDefaults¶
open fun setDefaults()
Sets the default values for all configuration fields.
setDefaultsFrom¶
open fun setDefaultsFrom(other: ViteConfig)