Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 5-Dev/QA构建使用带有丑陋和小型化的ng构建(如ng构建--prod)_Angular_Angular5_Angular Cli - Fatal编程技术网

Angular 5-Dev/QA构建使用带有丑陋和小型化的ng构建(如ng构建--prod)

Angular 5-Dev/QA构建使用带有丑陋和小型化的ng构建(如ng构建--prod),angular,angular5,angular-cli,Angular,Angular5,Angular Cli,我使用的是angular5和AngularCLI,需要在浏览器的inspector工具中查看丑陋/缩小代码。 My angular-cli.json具有: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } 对于生产,它通过ng

我使用的是angular5和AngularCLI,需要在浏览器的inspector工具中查看丑陋/缩小代码。 My angular-cli.json具有:

"environmentSource": "environments/environment.ts",
"environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
}
对于生产,它通过ng build--prod运行良好 但这只能用于生产环境。 我想为开发环境做同样的事情,但我无法做到。 我已经尝试过大多数具有产品价值的构建选项,除了环境:

Flag                 --dev    --prod
--aot                false    true
--environment        dev      prod
--output-hashing     media    all
--sourcemaps         true     false
--extract-css        false    true
--named-chunks       true     false
--build-optimizer    false    true with AOT and Angular 5
比如说

ng build --aot=true --output-hashing=all --sourcemaps=false --extract-css=true --named-chunks=false --build-optimizer true
但这对我不起作用。没有为这个环境创建丑陋的代码(这里是dev)


如何在其他环境中使用相同的生成命令?如何在其他环境中使用产品优化?

您可以通过在
angular cli.json
文件或
angular.json

angular-cli.json:

"environments": {
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts",
  "qa": "environments/environment.qa.ts"
}
angular.json:

"configurations": {
  "production": { ... },
  "qa": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.qa.ts"
      }
    ]
  }
}
然后在environments目录中创建
environment.qa.ts


如果您想将
开发
环境.ts
值与
--prod
优化一起使用,只需使用以下标志指定即可

ng build--prod--environment=dev

这将应用
--prod
设置,但会覆盖将对其使用环境文件的
--environment

在较新的Angular CLI版本中,更改为
Angular.json
,将
--environment
替换为
--configuration
。由于默认配置使用
environment.ts
,只需向其传递一个空字符串,这样环境文件就不会被覆盖,例如
--prod--configuration=