将Angular CLI与MVC 5 Razor页面集成

时间:2018-07-05 09:57:09

标签: asp.net angular asp.net-mvc-5 angular-cli

我们正在将角度集成到我们的FE零件解决方案中。我们的目标是在名为“ Angular”的文件夹中包含多个角度项目。

然后我们有了MVC项目。在这里,我们希望有一个搜索结果页面,该页面使用一个角度项目来获取结果项。

这里的问题是我们已经有了一个带有布局的cshtml页面。

当我们运行ng build search --prod命令时,我们在dist文件夹中看到index.html。

我们希望避免在运行此命令时将index.html文件复制到此文件夹中。

我们的配置如下:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "Search": {
      "root": "projects/Search/",
      "sourceRoot": "projects/Search/src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/Search",
            "index": "projects/Search/src/index.html",
            "main": "projects/Search/src/main.ts",
            "polyfills": "projects/Search/src/polyfills.ts",
            "tsConfig": "projects/Search/tsconfig.app.json",
            "assets": [],
            "styles": [],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "projects/Search/src/environments/environment.ts",
                  "with": "projects/Search/src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "sourceMap": false,
              "extractCss": false,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": false,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "Search:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "Search:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "Search:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/Search/src/test.ts",
            "polyfills": "projects/Search/src/polyfills.ts",
            "tsConfig": "projects/Search/tsconfig.spec.json",
            "karmaConfig": "projects/Search/karma.conf.js",
            "styles": [
              "projects/Search/src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "projects/Search/src/favicon.ico",
              "projects/Search/src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/Search/tsconfig.app.json",
              "projects/Search/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "Search-e2e": {
      "root": "projects/Search-e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "projects/Search-e2e/protractor.conf.js",
            "devServerTarget": "Search:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "Search:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "projects/Search-e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "Search"
}

0 个答案:

没有答案