-
Notifications
You must be signed in to change notification settings - Fork 7
Feat: define routes and ignore route files #69
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/imsobear/ice-next/522G1md9aHG1mYDePofTnppKQtL4 |
examples/basic-project/ice.config.ts
Outdated
// }, | ||
routes: { | ||
ignoreFiles: ['about.tsx'], | ||
defineRoutes: (route) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新建个 example 吧,不要把所有 feature 都放到一个 example 里面
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -89,14 +75,31 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt | |||
}, | |||
}); | |||
await ctx.resolveConfig(); | |||
const { userConfig: { routes: routesConfig } } = ctx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
routes 不存在的情况
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
packages/ice/src/createService.ts
Outdated
...renderData, | ||
...routesRenderData, | ||
})); | ||
dataCache.set('routes', JSON.stringify(routesRenderData)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可以顺便优化下仅缓存 manifest 信息
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/ice/src/getWatchEvents.ts
Outdated
@@ -49,7 +52,7 @@ const getWatchEvents = (options: Options): WatchEvent[] => { | |||
]; | |||
|
|||
const watchConfigFile: WatchEvent = [ | |||
new RegExp(configFile), | |||
new RegExp(configFile as string), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从 ctx 类型上解决
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
packages/ice/src/routes.ts
Outdated
|
||
export function generateRoutesInfo(rootDir: string) { | ||
const routeManifest = generateRouteManifest(rootDir); | ||
export function generateRoutesInfo(rootDir: string, routesConfig?: UserConfig['routes']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
routesConfig 为 undefined 的情况
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} else { | ||
pathList.push(route.path || '/'); | ||
pathList.push(path.join('/', parentPath, route.path || '')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSR 的时候需要特殊处理吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要的,生成的路由 manifest 中路由第一个字符不是 /
,这里需要加上 /
否则不能 match 上
#60