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),
});| Option | Default | Description |
|---|---|---|
paths | Required | Files/directories relative to Vite root or absolute paths; no globs |
debounce | 100 | Milliseconds used to coalesce file events |
forceOptimizeDeps | false | Force dependency prebundling on restart |
beforeRestart | - | Synchronous/asynchronous pre-restart hook; throwing cancels that restart |
log | true | Log 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
| Input | Type | Required / default | Description |
|---|---|---|---|
options | DevRestartPluginOptions | Required | Watch paths, debounce, prebundling, and pre-restart hook settings. |
Returns
| Value | Type | Description |
|---|---|---|
plugin | Plugin | Restart plugin active only in the development server. |
