新的@angular/cli 版本中的文件 angular-cli.json 在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42395200/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 18:48:21  来源:igfitidea点击:

Where is the file angular-cli.json in the new @angular/cli version?

jsonangularangular-cli

提问by ioses

I'm new in angular2 and i have tried to create a project with cli, but when I try to change the css adding it in angular-cli.json, I have detected that this file is not created...

我是 angular2 的新手,我尝试使用 cli 创建一个项目,但是当我尝试更改 css 并将其添加到 angular-cli.json 时,我检测到未创建此文件...

Can I create manually or this file has been changed for another one?

我可以手动创建还是此文件已更改为另一个?

Thanks!!

谢谢!!

采纳答案by Tyler Jennings

The angular-cli.jsonshould be located in the root folder of the project. This is using the latest version "@angular/cli": "1.0.0-beta.32.3".

angular-cli.json应位于项目的根文件夹。这是使用最新版本"@angular/cli": "1.0.0-beta.32.3"

As for creating it if it is missing or maybe accidentally deleted, you could try that since the original version is pretty generic. Here is what it should look like right after project creation:

至于创建它,如果它丢失或可能意外删除,您可以尝试,因为原始版本非常通用。下面是项目创建后的样子:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "version": "1.0.0-beta.32.3",
    "name": "testproj"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.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": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

You could also try generating a new project with the cli with ng new PROJECT_NAMEand see if it contains the angular-cli.jsonfile.

您也可以尝试使用 cli 生成一个新项目,ng new PROJECT_NAME看看它是否包含该angular-cli.json文件。

回答by Simon_Weaver

Angular 6 and later

Angular 6 及更高版本

angular-cli.jsonfile has been renamed/replaced with angular.jsonin version 6 of Angular.

angular-cli.json文件已angular.json在 Angular 版本 6 中重命名/替换。

It's a different file format and not just a rename :

这是一种不同的文件格式,而不仅仅是重命名:

https://github.com/angular/angular-cli/wiki/angular-workspace

https://github.com/angular/angular-cli/wiki/angular-workspace

回答by delasteve

The file was changed to be a hidden file now on unix/linux systems. It is now .angular-cli.json.

该文件现在已更改为 unix/linux 系统上的隐藏文件。现在是.angular-cli.json