我可以向Angular`ng serve`添加什么标志以使hotload显示严格的构建错误

时间:2018-01-24 15:10:02

标签: angular typescript angular-cli

我想在这篇文章的评论部分添加一个问题:Angular 2 AOT vs JIT,但我还没有足够的回复点。

我有一个Angular应用程序,在构建时显示错误,但在dev中没有。我理解在开发中获得快速反馈的愿望,但对于这个应用程序来说,在开发环境中工作了很长时间后,它会导致快速部署的满足问题。而不是ng serve来获取反馈,然后立即执行ng build以确保稍后我将能够部署;是否有我可以添加到ng serve的标志,我会为此做这个?

目前我使用ng serve --aot,但这并不足以显示在构建时失败的错误。现在我的应用程序并不是那么大,所以如果我的ng serve加载速度慢,我会觉得可以接受。

这是我的package.json的片段:

{
  "name": "XXXXXXX",
  "url": "XXXXXXX",
  "version": "0.0.1",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --aot",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.1.2",
    "@angular/cdk": "^5.0.2",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "^5.0.2",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/platform-server": "^5.0.0",
    "@angular/router": "^5.0.0",
    "angular2-jwt": "^0.2.3",
  },
  "devDependencies": {
    "@angular/cli": "^1.5.5",
    "@angular/compiler-cli": "^5.0.0",
    "@types/google.analytics": "0.0.36",
    "@types/jasmine": "^2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "^2.0.0",
    "tslint": "~4.5.0",
    "typescript": "^2.4.2"
  }
}

1 个答案:

答案 0 :(得分:0)

以下是ng服务

的所有构建选项的文档

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

对于您的情况,请尝试

ng serve --e=prod

ng serve --aot --e=prod

希望这有效。

同时尝试--source-maps = false。这看起来像加速了事情。