Angular Cli:如何投放2个应用程序?

时间:2016-12-06 18:11:07

标签: angular angular-cli

我在同一个项目中需要2个不同的应用程序:

  • index.html> mainApp模块
  • login.html> loginApp模块

(由于Spring Security管理的安全原因,这是必需的)

我vave angular-cli.json如下所述:

  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.scss"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    },
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "login.html",
      "main": "login.ts",
      "test": "login-test.ts",
      "tsconfig": "login-tsconfig.json",
      "prefix": "login-app",
      "mobile": false,
      "styles": [
        "login-styles.scss"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],

但只部署第一个(在“apps”数组上)。

如果我在位置[0]反转Login,则可以,但是mainApp模块没有。

显然原因是,Angular Cli没有在第二个html上注入创建的JS文件。

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:3)

  

更新:CLI现在支持多个应用 - 文档为here

目前,Angular CLI不支持多个应用。它将来会得到支持。

现在你可以在不同的目录下工作(也就是单独的CLI项目)。

答案 1 :(得分:0)

您可以编辑.angular-cli.json文件并设置多个应用

"apps": [
    {
      "root": "src",
      "outDir": "../Application.Web.UI/wwwroot/app/Candidate",
      "assets": [
        "assets"
      ],
      "index": "index.html",
      "main": "main.candidate.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app_andidate",
      "styles": [ "share/css/material.scss" ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    },
    {
      "root": "src",
      "outDir": "../Application.Web.UI/wwwroot/app/Company",
      "assets": [
        "assets"
      ],
      "index": "index.html",
      "main": "main.company.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app_company",
      "styles": [ "share/css/material.scss" ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],