routerMeta(options?)
Generates page-path-to-stable-component-name JSON for KeepAlive, permission metadata, and route caching.
ts
routerMeta({
dir: "src/views",
output: "src/router/routes.generated.json",
key: ({ relativePath }) => `@/${relativePath}`,
});| Option | Default | Description |
|---|---|---|
dir | "src/views" | Page directory |
output | "src/router/routes.generated.json" | JSON output |
deep | true | Recursive scanning |
extensions | vue, tsx, jsx | Page extensions |
include | - | Page filter |
name | - | Custom name; defaults to static defineOptions({ name }) when available |
key | - | Custom JSON key; defaults to /root-relative-path |
indent | 2 | JSON indentation from 0 to 10 |
debounce | 80 | Development watch debounce in milliseconds |
Only static string defineOptions names are parsed; dynamic expressions fall back to filenames.
routerMeta Routes
Generates a page-path/stable-component-name JSON mapping for routing caches, KeepAlive, or permissions.
Signature
ts
export function routerMeta(options: RouterMetaPluginOptions = {}): Plugin;Example
ts
import { routerMeta } from "fast-vite-plugins";
const plugin = routerMeta({ dir: "src/views", output: "src/router/routes.generated.json" });
export default { plugins: [plugin] };Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | RouterMetaPluginOptions | Optional; defaults to {} | Page scanning, naming, path keys, JSON output, and watch settings. |
Returns
| Value | Type | Description |
|---|---|---|
plugin | Plugin | Route metadata generation plugin for Vite plugins. |
