https://github.com/soybeanjs/vite-plugin-vue-page-route
vite插件,根据页面文件生成路由声明文件
https://github.com/soybeanjs/vite-plugin-vue-page-route
Last synced: over 1 year ago
JSON representation
vite插件,根据页面文件生成路由声明文件
- Host: GitHub
- URL: https://github.com/soybeanjs/vite-plugin-vue-page-route
- Owner: soybeanjs
- Created: 2022-10-26T12:17:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T16:27:10.000Z (about 3 years ago)
- Last Synced: 2025-04-10T13:18:06.225Z (over 1 year ago)
- Language: TypeScript
- Size: 342 KB
- Stars: 15
- Watchers: 2
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.en_US.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @soybeanjs/vite-plugin-vue-page-route
A Vite plugin for vue, auto generate route info by page, include route declaration, route file import, route module const.
## Usage
````ts
import { defineConfig } from "vite";
import pageRoute from "@soybeanjs/vite-plugin-vue-page-route";
export default defineConfig({
plugins: [
pageRoute({
pageDir: "src/views", // default
pageGlobs: ["**/index.{vue,tsx,jsx}", "!**/components/**"], // default
routeDts: "src/typings/page-route.d.ts", // default
routeModuleDir: "src/router/modules", // default
routeModuleExt: "ts", // default
routeModuleType: "AuthRoute.Route", // default
/**
* @example _builtin_login => login
*/
routeNameTansformer: (name) =>
name.replace(/^_([a-zA-Z]|[0-9]|$)+_*/, ""), // default
/**
* whether the route is lazy import
* @param name route name
* @example
* - the direct import
* ```ts
* import Home from './views/home/index.vue';
* ```
* - the lazy import
* ```ts
* const Home = import('./views/home/index.vue');
* ```
*/
lazyImport: (_name) => true, // default
/**
* whether generate the route module
* @param name the route name, which is not transformed(not execute function routeNameTansformer)
* @returns boolean
*/
onRouteModuleGenerate: (name) => !name.includes("_builtin"), // not generate route module for the builtin routes, but other routes will
}),
],
});
````