1

我正面临 ng serve angular7 的构建问题,每次构建需要超过 3 分钟,有时会增加到 5 分钟,我尝试了几个选项来提高速度,但运气不好,系统配置对构建也很重要。

如果有人遇到同样的问题或有什么想法,请帮忙,谢谢

角.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "IbCommand.Web": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "progress": true,
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets"
            ],
            "styles": [
              "node_modules/font-awesome/scss/font-awesome.scss",
              "node_modules/ng-uikit-pro-standard/assets/scss/bootstrap/bootstrap.scss",
              "node_modules/ng-uikit-pro-standard/assets/scss/mdb.scss",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/ngx-lightbox/lightbox.css",
              "node_modules/slick-carousel/slick/slick.scss",
              "node_modules/slick-carousel/slick/slick-theme.scss",
              "projects/shared/src/assets/style.css",
              "src/styles.scss"
            ],
            "stylePreprocessorOptions": {
              "includePaths": [
                "./node_modules/"
              ]
            },
            "scripts": [
              "node_modules/chart.js/dist/Chart.js",
              "node_modules/easy-pie-chart/dist/easypiechart.js",
              "node_modules/screenfull/dist/screenfull.js",
              "node_modules/hammerjs/hammer.min.js",
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
              "node_modules/moment/min/moment.min.js",
              "node_modules/fitty/dist/fitty.min.js",
              "node_modules/slick-carousel/slick/slick.min.js"
            ]
          },
          "configurations": {
            "exdev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.exdev.ts"
                },
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.dev.ts"
                }
              ]
            },
            "local": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.local.ts"
                },
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.local.ts"
                }
              ]
            },
            "qa": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.qa.ts"
                },
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.qa.ts"
                }
              ]
            },
            "prod": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                },
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.prod.ts"
                }
              ]
            },
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "IbCommand.Web:build"
          },
          "configurations": {
            "exdev": {
              "browserTarget": "IbCommand.Web:build:exdev"
            },
            "sandbox": {
              "browserTarget": "IbCommand.Web:build:sandbox"
            },
            "local": {
              "browserTarget": "IbCommand.Web:build:local"
            },
            "qa": {
              "browserTarget": "IbCommand.Web:build:qa"
            },
            "uat": {
              "browserTarget": "IbCommand.Web:build:uat"
            },
            "production": {
              "browserTarget": "IbCommand.Web:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "IbCommand.Web:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "codeCoverage": true,
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/chart.js/dist/Chart.js",
              "node_modules/easy-pie-chart/dist/easypiechart.js",
              "node_modules/screenfull/dist/screenfull.js",
              "node_modules/hammerjs/hammer.min.js",
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
              "node_modules/moment/min/moment.min.js",
              "node_modules/fitty/dist/fitty.min.js"
            ],
            "styles": [
              "node_modules/font-awesome/scss/font-awesome.scss",
              "node_modules/ng-uikit-pro-standard/assets/scss/bootstrap/bootstrap.scss",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/ngx-lightbox/lightbox.css",
              "src/styles.scss"
            ],
            "assets": [
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "IbCommand.Web-e2e": {
      "root": "e2e",
      "sourceRoot": "e2e",
      "projectType": "application",
      "architect": {

        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "trail": {
      "root": "projects/trail/",
      "sourceRoot": "projects/trail/src",
      "projectType": "application",
      "prefix": "ib",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/trail",
            "index": "projects/trail/src/index.html",
            "main": "projects/trail/src/main.ts",
            "polyfills": "projects/trail/src/polyfills.ts",
            "tsConfig": "projects/trail/tsconfig.app.json",
            "assets": [
              "projects/trail/src/favicon.ico",
              "projects/trail/src/assets"
            ],
            "styles": [
              "node_modules/font-awesome/css/font-awesome.css",
              "node_modules/ngx-toastr/toastr.css",
              "projects/trail/src/styles.scss",
              "node_modules/slick-carousel/slick/slick.scss",
              "node_modules/slick-carousel/slick/slick-theme.scss",
              "projects/shared/src/assets/style.css"
            ],
            "stylePreprocessorOptions": {
              "includePaths": [
                "./projects/trail/src/",
                "./node_modules/"
              ]
            },
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/slick-carousel/slick/slick.min.js"
            ],
            "es5BrowserSupport": true
          },
          "configurations": {
            "dev": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.dev.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.exdev.ts"
                }
              ]
            },
            "local": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.local.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.local.ts"
                }
              ]
            },
            "qa": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.qa.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.qa.ts"
                }
              ]
            },
                  "uat": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.uat.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.uat.ts"
                }
              ]
            },
            "sandbox": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.sandbox.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.sandbox.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "8mb",
                  "maximumError": "10mb"
                }
              ]
            },
            "demo": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.demo.ts"
                },
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.demo.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "8mb",
                  "maximumError": "10mb"
                }
              ]
            },
            "production": {
              "fileReplacements": [
                {
                  "replace": "projects/trail/src/environments/environment.ts",
                  "with": "projects/trail/src/environments/environment.prod.ts"
                },
                {
                  "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,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "4mb",
                  "maximumError": "7mb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "trail:build"
          },
          "configurations": {
            "dev": {
              "browserTarget": "trail:build:dev"
            },
            "local": {
              "browserTarget": "trail:build:local"
            },
            "qa": {
              "browserTarget": "trail:build:qa"
            },
            "uat": {
              "browserTarget": "trail:build:uat"
            },
            "production": {
              "browserTarget": "trail:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "trail:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "codeCoverage": true,
            "main": "projects/trail/src/test.ts",
            "polyfills": "projects/trail/src/polyfills.ts",
            "tsConfig": "projects/trail/tsconfig.spec.json",
            "karmaConfig": "projects/trail/karma.conf.js",
            "styles": [
              "projects/trail/src/styles.scss"
            ],
            "scripts": [],
            "assets": [
              "projects/trail/src/favicon.ico",
              "projects/trail/src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/trail/tsconfig.app.json",
              "projects/trail/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "trail-e2e": {
      "root": "projects/trail-e2e/",
      "projectType": "application",
      "prefix": "ibs",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "projects/trail-e2e/protractor.conf.js",
            "devServerTarget": "trail:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "trail:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "projects/trail-e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "shared": {
      "root": "projects/shared",
      "sourceRoot": "projects/shared/src",
      "projectType": "library",
      "prefix": "fcs",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "projects/shared/tsconfig.lib.json",
            "project": "projects/shared/ng-package.json"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "codeCoverage": true,
            "main": "projects/shared/src/test.ts",
            "tsConfig": "projects/shared/tsconfig.spec.json",
            "karmaConfig": "projects/shared/karma.conf.js"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/shared/tsconfig.lib.json",
              "projects/shared/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "IbCommand.Web",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "ib-cmd",
      "styleext": "scss"
    },
    "@schematics/angular:directive": {
      "prefix": "ib-cmd"
    }
  }
}

包.json

{
  "name": "IB.Web",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "start:local": "ng serve  --configuration=local",
    "start:trail": "ng serve trail --port 4300",
    "start:trail:local": "ng serve trail --port 4300 --configuration=local",
    "build": "ng build --aot=true --extract-css",
    "build:ssr": "npm run build --aot=true --app=ssr --output-hashing=media",
    "build:exdev": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --aot=true  --extract-css=true  --outputHashing=all --configuration=exdev",
    "build:qa": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --aot=true  --extract-css=true  --outputHashing=all --configuration=qa",
    "build:uat": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --aot=true  --extract-css=true  --outputHashing=all --configuration=uat",
    "build:sandbox": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --aot=true  --extract-css=true  --outputHashing=all --configuration=sandbox",
    "build:demo": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --aot=true  --extract-css=true  --outputHashing=all --configuration=demo",
    "build:prod": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod=true --sourceMap=false --extract-css=true --aot=true  --outputHashing=all --configuration=prod",
    "build:trail:dev": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c dev --baseHref=/trail/",
    "build:trail:qa": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c qa --baseHref=/trail/",
    "build:trail:uat": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c uat --baseHref=/trail/",
    "build:trail:sandbox": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c sandbox --baseHref=/trail/",
    "build:trail:demo": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c demo --baseHref=/trail/",
    "build:trail:prod": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build trail --aot=true --extract-css=true  --outputHashing=all -c production --baseHref=/trail/",
    "test:all": "ng test --reporters kjhtml",
    "test:ib-command": "ng test IbCommand.Web --reporters kjhtml",
    "test:trail": "ng test trail --reporters kjhtml",
    "test:shared": "ng test shared --reporters kjhtml",
    "test:ci:all": "ng test --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessCI",
    "test:ci:ib-command": "ng test --code-coverage IbCommand.Web --no-watch --no-progress --browsers=ChromeHeadlessCI",
    "test:ci:trail": "ng test --code-coverage trail --no-watch --no-progress --browsers=ChromeHeadlessCI",
    "test:ci:shared": "ng test --code-coverage shared --no-watch --no-progress --browsers=ChromeHeadlessCI",
    "coverage:report": "istanbul report cobertura --dir ./coverage/ci && istanbul report html --dir ./coverage/ci/html",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "e2e:trail": "ng e2e --port 4300 --protractor-config=projects/trail-e2e/protractor-ci.conf.js"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "1.0.0-beta.5",
    "@angular-devkit/core": "^7.1.4",
    "@angular-devkit/schematics": "^7.1.4",
    "@angular-redux/form": "^10.0.0",
    "@angular-redux/router": "^10.0.0",
    "@angular-redux/store": "^10.0.0",
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "^7.2.0",
    "@angular/cdk-experimental": "^7.3.7",
    "@angular/cli": "^7.1.4",
    "@angular/common": "^7.1.4",
    "@angular/compiler": "^7.1.4",
    "@angular/compiler-cli": "^7.1.4",
    "@angular/core": "^7.1.4",
    "@angular/forms": "^7.1.4",
    "@angular/http": "^7.1.4",
    "@angular/platform-browser": "^7.1.4",
    "@angular/platform-browser-dynamic": "^7.1.4",
    "@angular/platform-server": "^7.1.4",
    "@angular/router": "^7.1.4",
    "@auth0/angular-jwt": "^2.1.0",
    "@ng-bootstrap/ng-bootstrap": "4.1.1",
    "@nguniversal/module-map-ngfactory-loader": "^7.0.2",
    "@schematics/angular": "^7.1.4",
    "@types/file-saver": "^2.0.0",
    "@types/google-maps": "^3.2.0",
    "@types/mixpanel-browser": "^2.23.2",
    "@types/moment": "^2.13.0",
    "@types/node": "^10.12.18",
    "@types/ua-parser-js": "^0.7.32",
    "angular-google-charts": "^0.1.6",
    "angular-io-datepicker": "^1.3.1",
    "angular-tslint-rules": "^1.12.1",
    "angular4-datepicker": "^1.0.1",
    "aspnet-prerendering": "^3.0.1",
    "aws-sdk": "^2.382.0",
    "bootstrap": "^4.2.1",
    "chart.js": "^2.7.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.6.1",
    "decimal.js": "^10.2.0",
    "easy-pie-chart": "^2.1.7",
    "shared": "file:projects/shared",
    "file-saver": "^2.0.0",
    "fingerprintjs2": "^2.1.0",
    "fitty": "^2.2.6",
    "flatpickr": "^4.5.7",
    "flux-standard-action": "^2.1.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "html2canvas": "1.0.0-alpha.12",
    "immer": "^6.0.3",
    "jquery": "^3.3.1",
    "jspdf": "^1.5.3",
    "lodash": "^4.17.11",
    "mammoth": "^1.4.7",
    "mixpanel-browser": "^2.34.0",
    "moment": "^2.23.0",
    "moment-timezone": "^0.5.26",
    "mydatepicker": "^2.6.6",
    "ng-circle-progress": "^1.5.1",
    "ng-uikit-pro-standard": "git********",
    "ng2-pdf-viewer": "^5.2.3",
    "ng5-slider": "^1.2.4",
    "ngx-bootstrap": "5.1.2",
    "ngx-cookie-service": "^2.1.0",
    "ngx-json-viewer": "^2.4.0",
    "ngx-lightbox": "^1.2.0",
    "ngx-loading": "^3.0.1",
    "ngx-mask": "^7.9.1",
    "ngx-plaid-link": "^1.0.1",
    "ngx-scrollbar": "^4.2.0",
    "ngx-slick": "^0.2.1",
    "ngx-toastr": "^9.1.1",
    "ngx-toggle-switch": "^2.0.5",
    "node-sass": "^4.11.0",
    "popper.js": "^1.14.6",
    "redux": "4.0.1",
    "redux-devtools-extension": "^2.13.8",
    "redux-logger": "^3.0.6",
    "redux-observable": "^1.1.0",
    "redux-observable-es6-compat": "^1.2.0",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.5.2",
    "screenfull": "^4.0.0",
    "slick-carousel": "^1.8.1",
    "stream": "0.0.2",
    "tslib": "^1.9.0",
    "ua-parser-js": "^0.7.19",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.0",
    "@angular-devkit/build-ng-packagr": "~0.11.0",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "7.1.4",
    "@types/google-maps": "^3.2.0",
    "@types/googlemaps": "3.36.2",
    "@types/jasmine": "^3.3.5",
    "@types/jasminewd2": "^2.0.6",
    "@types/lodash": "^4.14.123",
    "codelyzer": "^4.5.0",
    "gulp": "^4.0.2",
    "gulp-inline-source": "^4.0.0",
    "istanbul": "^0.4.5",
    "istanbul-api": "^2.1.6",
    "istanbul-lib-coverage": "^2.0.5",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^3.1.4",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "^2.0.4",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "karma-junit-reporter": "^1.2.0",
    "ng-packagr": "^4.2.0",
    "protractor": "^5.4.2",
    "terser": "^3.14.1",
    "ts-node": "^7.0.1",
    "tsickle": ">=0.29.0",
    "tslib": "^1.9.0",
    "tslint": "^5.12.0",
    "tslint-language-service": "^0.9.9",
    "typescript": "^3.1.6"
  }
}

在此处输入图像描述

4

1 回答 1

0

请检查当您点击应用程序组件中的命令时加载了多少组件,我的建议是添加延迟加载可能是您的问题得到解决

于 2021-04-16T04:22:23.987 回答