【问题标题】:Build my Angular project without needing to specify long command options无需指定长命令选项即可构建我的 Angular 项目
【发布时间】:2020-08-17 23:51:46
【问题描述】:

我对 Angular CLI 有疑问。我想用长命令构建一个项目:ng build --prod --aot=false --output-hashing none。有没有办法在 gulp 中创建类似任务的东西并使用例如ng build my-task 运行该任务序列?

【问题讨论】:

  • 你使用哪个版本的 Angular?
  • 我使用的是 Angular 6
  • 我的回答有帮助吗?

标签: angular angular-cli


【解决方案1】:

由于您使用的是 Angular 6,因此您可以根据需要调整 angular.json。

"configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",<--none
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,<---false
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },

或者,您可以修改 package.json 中现有的构建脚本

"scripts": {
    "ng": "ng",
    "start": "ng serve --prod",
    "build": "ng build --prod --aot=false --output-hashing none",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },

执行npm run-script buildnpm run build

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-21
    • 2023-03-10
    • 1970-01-01
    • 2018-12-15
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 2017-05-31
    相关资源
    最近更新 更多