angular - 使用 Angular cli 在同一端口上运行两个单独的应用程序

标签 angular angular-cli

我想在同一端口上运行两个单独的应用程序,一个用于“客户”,另一个用于“管理员”。在 angular cli 中,您可以在 .angular-cli.json 中添加多个应用程序,但不能同时运行它们。有谁知道我该如何解决这个问题?

最佳答案

您可以创建一个包含这两个应用程序的新模块。
1. 向 .angular-cli.json 添加一个新应用:

"apps": [
{
  "name": "all",
  "root": "src",
  "outDir": "dist",
  "assets": [
    "assets",
    "favicon.ico"
  ],
  "index": "index.html",
  "main": "main-all.ts",
  "polyfills": "polyfills.ts",
  "environmentSource": "environments/environment.ts",
  "environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  }
}, .......

2。像为其他应用程序一样创建 main-all.ts 文件。 https://github.com/angular/angular-cli/wiki/stories-multiple-apps

3.创建一个公共(public)模块:

@NgModule({
  declarations: [],
  imports: [
    AppModule1,
    AppModule2
  ],
  providers: [],
  bootstrap: [AppComponent1, AppComponent2]
})
export class AppModuleAll {}

关于angular - 使用 Angular cli 在同一端口上运行两个单独的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45630548/

相关文章:

angular - 如何知道@Input何时发生变化?

angular - 如何构建 Angular 4.3.6 进行生产?

node.js - 在企业环境中创建 Angular 项目(无互联网)

javascript - 在 Angular 应用程序中使用 Webworkers(服务 worker 在 angular-cli 中缓存数据访问)

.net - Spa 模板 .net 核心 2.0 Angular 4 webpack 2 使用 sass 不引导 4 css

angular - 组件是两个模块 :AppRoutingModule and AppModule 声明的一部分

node.js - Angular 7 应用程序从 Angular 客户端获取 CORS 错误

angular - ng build --prod 问题

angular - 在静态和非 SPA Web 应用程序中使用 Angular 2 组件

javascript - 错误 : Dependency @types/html2canvas must be explicitly allowed using the "allowedNonPeerDependencies" option