datahub-mfe-configure-app
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfigure an MFE in DataHub
在DataHub中配置MFE
Walks through registering a Micro Frontend app with the DataHub frontend so it
loads at and optionally appears in the navigation sidebar. Covers
local development, production/k8s deployment, and troubleshooting.
/mfe/<path>本文将介绍如何向DataHub前端注册微前端(MFE)应用,使其在路径下加载,并可选择显示在导航侧边栏中。内容涵盖本地开发、生产/K8s部署以及问题排查。
/mfe/<path>Step 1: Gather Information
步骤1:收集信息
Use the AskQuestion tool to collect the following in a single call.
| Question | ID | Options |
|---|---|---|
| Are you configuring for local development or production/k8s? | | |
MFE app name — the | | |
URL path where the MFE should be accessible, e.g. | | |
| | |
Display label for navigation, e.g. | | |
| Should the MFE appear in the left nav sidebar? | | |
| Nav icon | | |
If is Local development, ask one follow-up question using
AskQuestion before proceeding:
env_target| Question | ID | Options |
|---|---|---|
| How are you running DataHub locally? | | |
For the fields (, ,
, ), do NOT invent or suggest values from the
workspace. The user will type their own.
N/A - I'll fill it in latermf_namemfe_pathremote_entry_urldisplay_labelFinding the MFE app name: Open the MFE'sand look for thewebpack.config.jsblock. TheModuleFederationPluginproperty is what goes here:namejsnew ModuleFederationPlugin({ name: 'teamDashboardMFE', ... }) // ^^^^^^^^^^^^^^^^^ ← this valueIf the name in the YAML config doesn't match this exactly, the MFE will fail to load. If you used theskill, the name was printed in the summary as "Module Federation name".datahub-mfe-create-app
使用AskQuestion工具一次性收集以下信息。
| 问题 | ID | 选项 |
|---|---|---|
| 你是为本地开发还是生产/K8s环境进行配置? | | |
MFE应用名称 —— MFE的 | | |
MFE可访问的URL路径,例如 | | |
| | |
导航显示标签,例如 | | |
| 是否要在左侧导航侧边栏显示该MFE? | | |
| 导航图标 | | |
如果为Local development,在继续前使用AskQuestion询问一个后续问题:
env_target| 问题 | ID | 选项 |
|---|---|---|
| 你在本地如何运行DataHub? | | |
对于标记为的字段(、、、),请勿从工作区中生成或建议值,用户将自行输入。
N/A - I'll fill it in latermf_namemfe_pathremote_entry_urldisplay_label查找MFE应用名称:打开MFE的,找到webpack.config.js代码块。ModuleFederationPlugin属性即为所需值:namejsnew ModuleFederationPlugin({ name: 'teamDashboardMFE', ... }) // ^^^^^^^^^^^^^^^^^ ← 这个值如果YAML配置中的名称与该值不完全匹配,MFE将加载失败。如果你使用了技能,该名称会在摘要中以“Module Federation name”的形式显示。datahub-mfe-create-app
Step 2: Generate the YAML Config Entry
步骤2:生成YAML配置条目
Build the config entry from the gathered values:
yaml
- id: __MFE_ID__
label: __DISPLAY_LABEL__
path: __MFE_PATH__
remoteEntry: __REMOTE_ENTRY_URL__
module: __MF_NAME__/mount
flags:
enabled: true
showInNav: __SHOW_IN_NAV__
navIcon: __NAV_ICON__Where is derived from the path (strip leading , replace
with ), e.g. path becomes id .
__MFE_ID__//-/dashboarddashboard根据收集到的值构建配置条目:
yaml
- id: __MFE_ID__
label: __DISPLAY_LABEL__
path: __MFE_PATH__
remoteEntry: __REMOTE_ENTRY_URL__
module: __MF_NAME__/mount
flags:
enabled: true
showInNav: __SHOW_IN_NAV__
navIcon: __NAV_ICON__其中由路径派生(去除开头的,将替换为),例如路径会变为id 。
__MFE_ID__//-/dashboarddashboardStep 3: Apply the Configuration
步骤3:应用配置
Local Development — Docker / datahub-dev.sh
(standard)
datahub-dev.sh本地开发 —— Docker / datahub-dev.sh
(标准方式)
datahub-dev.shThe Docker image has baked in at build time pointing to
(set in ).
This is the file to edit for any Docker-based workflow.
MFE_CONFIG_FILE_PATH/datahub-frontend/conf/mfe.config.dev.yamldocker/datahub-frontend/Dockerfile- Read the current .
datahub-frontend/conf/mfe.config.dev.yaml - Append the new entry under . If the file is empty, use:
microFrontends:
yaml
subNavigationMode: false
microFrontends:
- id: ...
...- Rebuild the frontend container so the updated file is baked into the image:
bash
scripts/dev/datahub-dev.sh rebuild --waitDocker镜像在构建时内置了,指向(在中设置)。任何基于Docker的工作流都需要编辑此文件。
MFE_CONFIG_FILE_PATH/datahub-frontend/conf/mfe.config.dev.yamldocker/datahub-frontend/Dockerfile- 读取当前的文件。
datahub-frontend/conf/mfe.config.dev.yaml - 在下追加新条目。如果文件为空,请使用:
microFrontends:
yaml
subNavigationMode: false
microFrontends:
- id: ...
...- 重新构建前端容器,使更新后的文件被打包到镜像中:
bash
scripts/dev/datahub-dev.sh rebuild --waitLocal Development — Play server directly (sbt / IntelliJ)
本地开发 —— 直接运行Play服务器(sbt / IntelliJ)
datahub-frontend/run/frontend.envMFE_CONFIG_FILE_PATH../conf/mfe.config.local.yaml- Read the current .
datahub-frontend/conf/mfe.config.local.yaml - Append the new entry under .
microFrontends: - Restart the Play server — no rebuild needed, the file is read from disk:
bash
cd datahub-frontend/run && ./run-local-frontenddatahub-frontend/run/frontend.envMFE_CONFIG_FILE_PATH../conf/mfe.config.local.yaml- 读取当前的文件。
datahub-frontend/conf/mfe.config.local.yaml - 在下追加新条目。
microFrontends: - 重启Play服务器 —— 无需重新构建,文件将从磁盘读取:
bash
cd datahub-frontend/run && ./run-local-frontendProduction / Kubernetes
生产 / Kubernetes
Tell the user:
Since you selected Production / Kubernetes, I won't edit any local config files — instead here's what you need.
-
Show the user the complete YAML config to add to their production config file (which may live in a separate config repo).
-
Explain the env var and volume mount setup. See reference.md for the full k8s ConfigMap pattern.
-
Remind the user about:
MFE_PUBLIC_PATH
When deploying your MFE to a CDN or static host, set theenv var during the MFE's production build so webpack knows the correct public URL for chunk loading.MFE_PUBLIC_PATHbashMFE_PUBLIC_PATH=https://cdn.example.com/my-mfe/ npm run build
告知用户:
由于你选择了Production / Kubernetes,我不会编辑任何本地配置文件 —— 以下是你需要执行的操作。
-
向用户展示需要添加到生产配置文件中的完整YAML配置(该文件可能存放在单独的配置仓库中)。
-
解释环境变量和卷挂载设置。有关完整的K8s ConfigMap模式,请参阅reference.md。
-
提醒用户注意:
MFE_PUBLIC_PATH
将MFE部署到CDN或静态主机时,在MFE的生产构建过程中设置环境变量,以便webpack知道块加载的正确公共URL。MFE_PUBLIC_PATHbashMFE_PUBLIC_PATH=https://cdn.example.com/my-mfe/ npm run build
Step 4: Verify
步骤4:验证
Guide the user through these checks:
-
Standalone check: Openin a browser — should return JavaScript content (not 404 or HTML).
__REMOTE_ENTRY_URL__ -
Integration check: Navigate to(local) or the equivalent production URL. The MFE should render inside the DataHub chrome.
http://localhost:9002/mfe__MFE_PATH__ -
Nav check (if): The sidebar should show the
showInNav: trueitem with the chosen icon. Click it to navigate.__DISPLAY_LABEL__
If any check fails, see the Troubleshooting section in reference.md.
引导用户完成以下检查:
-
独立检查:在浏览器中打开—— 应返回JavaScript内容(而非404或HTML)。
__REMOTE_ENTRY_URL__ -
集成检查:导航到(本地环境)或对应的生产URL。MFE应在DataHub的框架内渲染。
http://localhost:9002/mfe__MFE_PATH__ -
导航检查(如果):侧边栏应显示带有所选图标的
showInNav: true项。点击该项进行导航。__DISPLAY_LABEL__
如果任何检查失败,请参阅reference.md中的故障排除部分。
Step 5: Summary
步骤5:总结
Provide the user with a summary. Show only the config file relevant to their
— do not mention local config files if they selected Production.
env_targetIf local development:
MFE registered in DataHub:
Path: /mfe__MFE_PATH__
Remote entry: __REMOTE_ENTRY_URL__
Module: __MF_NAME__/mount
Nav sidebar: __SHOW_IN_NAV__ (icon: __NAV_ICON__)
Config file: datahub-frontend/conf/mfe.config.dev.yaml (Docker / datahub-dev.sh)
datahub-frontend/conf/mfe.config.local.yaml (Play server / IntelliJ)If Production / Kubernetes:
MFE registered in DataHub:
Path: /mfe__MFE_PATH__
Remote entry: __REMOTE_ENTRY_URL__
Module: __MF_NAME__/mount
Nav sidebar: __SHOW_IN_NAV__ (icon: __NAV_ICON__)
Config file: <your production config file>为用户提供总结。仅显示与他们的相关的配置文件 —— 如果用户选择了生产环境,请勿提及本地配置文件。
env_target如果是本地开发:
已在DataHub中注册MFE:
路径: /mfe__MFE_PATH__
远程入口: __REMOTE_ENTRY_URL__
模块: __MF_NAME__/mount
导航侧边栏: __SHOW_IN_NAV__ (图标: __NAV_ICON__)
配置文件: datahub-frontend/conf/mfe.config.dev.yaml (Docker / datahub-dev.sh)
datahub-frontend/conf/mfe.config.local.yaml (Play server / IntelliJ)如果是Production / Kubernetes:
已在DataHub中注册MFE:
路径: /mfe__MFE_PATH__
远程入口: __REMOTE_ENTRY_URL__
模块: __MF_NAME__/mount
导航侧边栏: __SHOW_IN_NAV__ (图标: __NAV_ICON__)
配置文件: <你的生产配置文件>