如何生成 Angular.json 文件 [英] How to generate Angular.json file

查看:36
本文介绍了如何生成 Angular.json 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的应用程序是 Angular 4,没有 Angular CLI.所以我从来没有 Angualr.json 文件或 Angular-cli.json 文件.现在我们要生成 Angular CLI 或 angular.json 文件.由于此文件不可用,因此它不会执行任何 ng 命令,例如 ng serve 或 ng g c testing

My current application was in Angular 4 without Angular CLI. So I never had Angualr.json file or Angular-cli.json file. Now we want to generate that Angular CLI or angular.json file. Because this file is not available it is not taking any of the ng commands like ng serve or ng g c testing

如何在不使用 ng new 命令的情况下生成文件,因为 ng new 将创建一个我不想要的新项目.我想支持我现有的项目.

How can I generate the file without using ng new command because ng new will create a new project which I don't want. I want to support my existing project.

关于我的项目的一些注意事项:1.我们从一个文件夹启动多个应用程序2. 我们从 ASPX 页面启动每个应用程序,而不使用 index.html.

Few notes on my project : 1. We are launching multiple application from one folder 2. We are launching each application from the ASPX page without using index.html.

请看我项目的错误截图和文件夹结构输入图片描述这里

Please see the screen shot attached of the error and the folder structure of my projectenter image description here

在此处输入图片说明

推荐答案

创建一个名为.angular-cli.json"的新文件并将该文件添加到您的主目录中.

Create a new file with name '.angular-cli.json' and add this file in your main directory.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "my-app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

这篇关于如何生成 Angular.json 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆