vite-plugin-generoutes 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84,7 +84,7 @@ function VitePluginGeneroutes(options = {}) {
|
|
|
84
84
|
return null;
|
|
85
85
|
const pathSegments = filePath.replace(`${pagesFolder}`, "").replace(".vue", "").replace("index", "").split("/").filter((item) => !!item && !/^\(.*\)$/.test(item));
|
|
86
86
|
const name = defineOptions.name || pathSegments.map((item) => toPascalCase(item)).join("_") || "Index";
|
|
87
|
-
const component = `##/${filePath}##`;
|
|
87
|
+
const component = `##/${filePath}@@${name}##`;
|
|
88
88
|
const routePath = `/${pathSegments.map((item) => item.replace(/\[(.*?)\]/g, (_, p1) => p1 === "...all" ? ":pathMatch(.*)*" : p1.split(",").map((i) => `:${i}`).join("/"))).join("/")}`;
|
|
89
89
|
return {
|
|
90
90
|
name,
|
|
@@ -112,7 +112,7 @@ function VitePluginGeneroutes(options = {}) {
|
|
|
112
112
|
|
|
113
113
|
export const routes = ${JSON.stringify(routes, null, 2)}
|
|
114
114
|
`;
|
|
115
|
-
routesStr = routesStr.replace(/"##(.*)##"/g, (_, p1) => `() => import('${p1}')`);
|
|
115
|
+
routesStr = routesStr.replace(/"##(.*)##"/g, (_, p1) => `async () => ({...(await import('${p1.split("@@")[0]}')).default, name: '${p1.split("@@")[1]}'})`);
|
|
116
116
|
routesStr = await prettier.format(routesStr, { parser: "babel", semi: false, singleQuote: true });
|
|
117
117
|
const filePath = path.resolve(rootDir, routesPath);
|
|
118
118
|
await fs.ensureDir(path.dirname(filePath));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-generoutes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"packageManager": "pnpm@9.1.1",
|
|
6
6
|
"description": "A Vite plugin that generate routes based on the file structure, supports dynamic routes, and supports custom meta data for each route.",
|
|
7
7
|
"author": "Ronnie Zhang <zclzone@outlook.com>",
|