Shared Options
These are the top-level fields of the config object — paths, the public base, global constants, and plugins. They apply across dev, build, and preview.
root
- Type:
string - Default:
"."
Project root, resolved relative to the current working directory. The index.html entry and every other directory below are resolved relative to this root.
export default defineConfig({ root: "." });Most projects leave this as the default and run Vantris from the project directory.
rootDir
- Type:
string - Default:
"./src"
Directory containing application source files. In dev, source modules are served from here under /src/*. In the build, HTML src/href references that point into rootDir are hashed and rewritten.
export default defineConfig({ rootDir: "./app" });publicDir
- Type:
string - Default:
"./public"
Directory of static assets served as-is. Contents are served at the root URL in dev (public/favicon.svg → /favicon.svg) and copied verbatim into outDir on build — never hashed, never transformed.
export default defineConfig({ publicDir: "./static" });outDir
- Type:
string - Default:
"./dist"
Output directory for production builds. Emptied before each build (guarded so it can never remove anything outside it — see build.emptyOutDir) and served as-is by vantris preview.
export default defineConfig({ outDir: "./build" });base
- Type:
string - Default:
"/"
Public base path the app is served from. Prefixed to built asset and entry URLs so they resolve correctly when deployed under a sub-path or a CDN. Normalised to always start and end with /.
export default defineConfig({ base: "/" }); // root (default)
export default defineConfig({ base: "/my-app/" }); // sub-path
export default defineConfig({ base: "https://cdn.example.com/assets/" }); // CDNbase is applied consistently across HTML, CSS url(), injected stylesheets, and JS-imported assets. Dynamic-import chunks stay relative so they resolve under any base. It also becomes import.meta.env.BASE_URL. See Building → base.
define
- Type:
Record<string, string | number | boolean> - Default:
{}
Global constant replacements. Each key is replaced — verbatim, as a JSON literal — wherever it appears in your code, in both development and build. Use it for compile-time flags and metadata that should be inlined (and tree-shaken).
export default defineConfig({
define: {
__DEV__: true,
__APP_VERSION__: "1.0.0",
},
});if (__DEV__) console.log("dev only"); // dropped when __DEV__ is false
console.log(__APP_VERSION__); // → console.log("1.0.0")Values are string, number, or boolean. See the Define guide.
plugins
- Type:
string[] - Default:
[]
Plugins, referenced by string — either a package name or a path to a local plugin file. Each is loaded from the project root and its default export (a plugin object via definePlugin, or a function returning one) is used.
export default defineConfig({
plugins: ["@vantris/react", "./plugins/my-plugin"],
});Plugins extend the dev server and build with hooks for config, resolveId, load, transform, handleHotUpdate, and more. To pass options to a string-referenced plugin, wrap it in a local module and reference that file. See the Plugin system and @vantris/react → With options.
dev, server, build, preview, resolve, optimizeDeps
These nested blocks each have their own reference page: