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

Improve umi plugin system #87

Closed
19 tasks done
sorrycc opened this issue Feb 2, 2018 · 1 comment
Closed
19 tasks done

Improve umi plugin system #87

sorrycc opened this issue Feb 2, 2018 · 1 comment

Comments

@sorrycc
Copy link
Member

sorrycc commented Feb 2, 2018

生命周期

  • 前置任务,在做所有事之前,onStart
  • 更新全局配置,Service.js#constructor,_modifyGlobalConfig
  • 修改路由配置,getRouteConfig.js#default,modifyRoutes
  • 修改配置插件,modifyConfigPlugins
  • 生成 .umi 下的文件,generateFiles
  • modifyPageWatchers
  • 修改路由文件,modifyRouterFile
  • 修改入口文件 umi.js,modifyEntryFile
  • 修改路由文件里 component 的定义,区分 development 和 production,modifyRouteComponent
  • 修改传给 af-webpack/getConfig 的参数,modifyAFWebpackOpts
  • 修改 webpack config,modifyWebpackConfig
  • 修改 HTML 文件,modifyHTML
  • 修改 HTML 的 script 部分,modifyHTMLScript
  • build 成功后,buildSuccess

dev 专用

  • modifyMiddlewares
  • 路由被请求时做的事,onRouteRequest
  • afterServer
  • beforeServer
  • onCompileDone

注意:

  • _ 开始的接口为私有接口,需尽量避免使用,可能会变更

Plugin Example

export default function(api) {
  api.registerCommand('command', fn);
  api.register('key', fn);
}
@sorrycc
Copy link
Member Author

sorrycc commented Feb 6, 2018

Done。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant