本文介绍了如何使用 Angular CLI 创建一个新的遥控器?(Webpack 5 Module Federation 微前端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个名为 myShellAngular 12 项目中,我实现了一个 nx monorepo,然后将我的项目定义为一个 Webpack5 Module Federation 微前端shell 使用命令ng add @angular-architects/module-federation --project myShell --port 4200.

In an Angular 12 project called myShell, I've implemented an nx monorepo, then defined my project as a Webpack 5 Module Federation micro frontend shell using the command ng add @angular-architects/module-federation --project myShell --port 4200.

现在我想使用 Angular CLI 来生成一个新的微前端 remote,我将其命名为 mfe1.我将如何使用 nxng CLI 完成此操作?例如,如果我导航到我的 apps 文件夹(其中包含 myShell 项目)并执行 ng new mfe1,我会收到错误消息: 新命令需要在项目之外运行,但在 ...filepath/angular.json 中找到了项目定义.我也无法运行 ng g c,因为 Angular 微前端应用不仅仅是一个简单的组件.

Now I'd like to use the Angular CLI to generate a new micro frontend remote, which I'll name mfe1. How would I accomplish this with the nx or ng CLI? For example, if I navigate to my apps folder (which contains the myShell project) and do an ng new mfe1, I get the error message: The new command requires to be run outside of a project, but a project definition was found at ...filepath/angular.json. I also can't run an ng g c, since an Angular micro frontend app is more than a simple component.

是否有一个 Angular CLI 命令可以用来创建一个新的微前端远程,或者每个远程应用程序都必须手动创建?

Is there an Angular CLI command that I can use to create a new micro frontend remote, or must each remote application be created tediously by hand?

推荐答案

ng new 命令将创建一个新的工作区.所以你不能在已经包含 angular.json 文件的文件夹中使用它.

The ng new command will create a new workspace. So you can't use it inside a folder alread containing an angular.json file.

您可以使用命令 ng g application

例如:

ng g application mfe1 --routing --style=scss

这篇关于如何使用 Angular CLI 创建一个新的遥控器?(Webpack 5 Module Federation 微前端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 12:53