Как улучшить скорость компиляции в angular - PullRequest
0 голосов
/ 18 июня 2020

Как мне скомпилировать в Angular быстрее? Обычно мой проект занимает 617794 мс только на одно обновление кода. Вот мой журнал:

enter image description here

This is my angular.json

=========================   angular.json ========================

{"$ schema": "./node_modules/@angular/cli/lib/config/schema . json "," version ": 1," newProject Root ":" projects "," projects ": {" hypeProject ": {" root ":" "," source Root ":" sr c "," projectType ":" application "," prefix ":" app "," schematics ": {

  },
  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/hypeProject",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.app.json",
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          {
            "input": "node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
          },
          "src/styles.css",
          "node_modules/datatables.net-dt/css/jquery.dataTables.css",
          "src/app/_content/app.less",
          "src/app/_content/modal.less"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.js",
         "node_modules/datatables.net/js/jquery.dataTables.js"
        ]
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        },
        "dev": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.dev.ts"
            }
          ],
          "optimization": false,
          "outputHashing": "all",
          "sourceMap": true,
          "extractCss": false,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": false,
          "vendorChunk": false,
          "buildOptimizer": false
        },
        "local": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.local.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "hypeProject:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "hypeProject:build:production"
        },
        "dev": {
          "browserTarget": "hypeProject:build:dev"
        },
        "local": {
          "browserTarget": "hypeProject:build:local",
          "port": 8200,
          "host": "localhost"

        }
      }
    },
    "extract-i18n": {
      "builder": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "hypeProject:build"
      }
    },
    "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.spec.json",
        "karmaConfig": "src/karma.conf.js",
        "styles": [
          {
            "input": "node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
          },
          "src/styles.css"
        ],
        "scripts": [],
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ]
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }
},
"danaonline-e2e": {
  "root": "e2e/",
  "projectType": "application",
  "architect": {
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "e2e/protractor.conf.js",
        "devServerTarget": "hypeProject:serve"
      },
      "configurations": {
        "production": {
          "devServerTarget": "hypeProject:serve"
        },
        "dev": {
          "devServerTarget": "hypeProject:serve"
        },
        "local": {
          "devServerTarget": "hypeProject:serve"
        }
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": "e2e/tsconfig.e2e.json",
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }
}

}," defaultProject ":" hypeProject "}

1 Ответ

0 голосов
/ 18 июня 2020

Судя по вашему снимку экрана, похоже, что вы используете buildOptimization, что занимает слишком много времени, добавьте эти свойства в конфигурацию сборки в angular.json:

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