首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >具有共享特征的角MFE

具有共享特征的角MFE
EN

Stack Overflow用户
提问于 2021-12-14 00:58:44
回答 1查看 475关注 0票数 0

我正在致力于一个具有微前端架构的角11项目。我的门户有多个被开发为MFE的应用程序。我确实有很多常见的设计组件,比如表单、表和仪表板etc.what是最好的实现方法,可以让这些组件在MFE中作为可重用的?

EN

回答 1

Stack Overflow用户

发布于 2022-01-07 15:40:15

如果您在@angular-architects/module-federation/webpack中使用MFE,您可以创建一个共享库(我主要使用NX )。示例配置:

代码语言:javascript
运行
复制
const sharedMappings = new SharedMappings();
sharedMappings.register(tsConfigPath, ['@xxx/shared-components'], workspaceRootPath);

// inside your module.export //
 new ModuleFederationPlugin({
  name: 'xxx',
  filename: 'xxx',
  exposes: {
    './Login': 'apps/frontend/auth/src/app/modules/login/login.module.ts'
  },
  shared: share({
    '@angular/core': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
    '@angular/common': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
    '@angular/common/http': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
    '@angular/router': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
    ...sharedMappings.getDescriptors(),
  }),

您可以找到更多有关这方面的信息:模块联合插件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70342623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档