Skip to content

devRestart(options) ​

Watches configuration, schemas, or generator inputs outside the module graph and debounces development-server restarts.

ts
devRestart({
	paths: ["schema", "config/features.json"],
	debounce: 100,
	beforeRestart: async ({ file, event }) => auditChange(file, event),
});
OptionDefaultDescription
pathsRequiredFiles/directories relative to Vite root or absolute paths; no globs
debounce100Milliseconds used to coalesce file events
forceOptimizeDepsfalseForce dependency prebundling on restart
beforeRestart-Synchronous/asynchronous pre-restart hook; throwing cancels that restart
logtrueLog the last relative path triggering restart

Directories existing at startup match descendants; nonexistent paths are treated as exact files. Vite already watches its config and .env, so do not duplicate them.

devRestart Restart ​

Restarts Vite development when external config, code-generation inputs, or monorepo shared files change.

Vite already watches vite.config and .env. This plugin handles files outside the module graph that influence plugin initialization. Production builds register no watchers.

Signature ​

ts
export function devRestart(options: DevRestartPluginOptions): Plugin;

Example ​

ts
import { devRestart } from "fast-vite-plugins";

const plugin = devRestart({ paths: ["schema", "config/features.json"], debounce: 100 });

export default { plugins: [plugin] };

Input ​

InputTypeRequired / defaultDescription
optionsDevRestartPluginOptionsRequiredWatch paths, debounce, prebundling, and pre-restart hook settings.

Returns ​

ValueTypeDescription
pluginPluginRestart plugin active only in the development server.