Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Improve conventional router for complex project: only read index.js #2412

Closed
yutingzhao1991 opened this issue May 14, 2019 · 2 comments
Labels

Comments

@yutingzhao1991
Copy link
Contributor

Background

约定式路由可以让文件结构和路由直接对应上,减少了隐含存在的一份路由配置的冗余,同时也让查看项目结构变得更方便,开发起来也少了一些工作。但是对于大型项目来说存在一个问题:

  • 路由组件太大之后需要拆分为多个组件,拆分出来的内容需要 ignore 掉,不然会被识别为约定式路由。

Proposal

约定式路由是否可以只识别 index.js。

@xiaohuoni
Copy link
Member

xiaohuoni commented May 15, 2019

我现在在alita里面就是这么处理的,只有index.js生效。但是在需要约定式嵌套路由的时候,很不好处理。(因为我们公司项目,没有用到约定式嵌套路由的情况,只在 layout/index.js 里面做了 layout 区分)
在umi项目中,你可以尝试配置routes

routes: {
      // 规定只有index文件会被识别成路由
      exclude: [
        /(?<![\s\S]*index\$?\.(js|jsx|ts|tsx)?)$/,
        /model\.(j|t)sx?$/,
        /\.test\.(j|t)sx?$/,
        /service\.(j|t)sx?$/,
        /models\//,
        /components\//,
        /services\//
      ]
    },

@stale
Copy link

stale bot commented Jul 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 14, 2019
@stale stale bot closed this as completed Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants