6

我们有一个 Angular 5 应用程序,它使用 Auth0 来处理我们所有的授权要求。它已经开发了大约一年。所以我们最初从 Angular2 开始,分别升级到 3、4 和现在的 5。缓慢的加载时间一直是一个问题。

我们在项目中使用 npm auth0 sdk。它托管在 s3 存储桶上。该项目使用 angular-cli 通过 webpack 构建。

有没有其他人经历过这个?有已知的解决方案吗?我们使用 uglify 来缩小一切。锁定屏幕很快就会显示出来,但是提交用户名/密码以点击回调/服务器身份验证然后加载仪表板的整个过程需要 20-30 秒。感觉就像一辈子。

我将附上我们的 angular-cli.json 文件和我们的 package.json 文件,让您了解应用程序中的所有内容。

角-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "ng2angle"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "app/core/preloader/preloader.scss",
        "styles.scss"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "app/core/preloader/preloader.js",
        "../node_modules/flot/jquery.flot.js",
        "../node_modules/jquery.flot.tooltip/js/jquery.flot.tooltip.js",
        "../node_modules/flot/jquery.flot.resize.js",
        "../node_modules/flot/jquery.flot.pie.js",
        "../node_modules/flot/jquery.flot.time.js",
        "../node_modules/flot/jquery.flot.categories.js",
        "../node_modules/easy-pie-chart/dist/easypiechart.js",
        "../node_modules/chart.js/dist/Chart.bundle.js",
        "../node_modules/bootstrap/js/modal.js",
        "../node_modules/bootstrap/js/dropdown.js",
        "../node_modules/bootstrap/js/tooltip.js",
        "../node_modules/summernote/dist/summernote.js",
        "../node_modules/moment/min/moment-with-locales.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts",
        "staging": "environments/environment.staging.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    },
    "build": {
      "showCircularDependencies": false
    }
  }
}

包.json

{
  "name": "moleadaggregation",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build-staging": "ng build --env=staging --aot=false --target=development && node ./build-post.js",
    "build-prod": "ng build --prod --aot=false --target=production && node ./build-post.js",
    "build-docs": "./node_modules/.bin/compodoc -d docs -p src/tsconfig.app.json --disableSourceCode --theme readthedocs -n \"Mo Lead Aggregation\"",
    "test": "ng test",
    "lint": "ng lint",
    "modernizr": "modernizr -c modernizr-config.json -d src/modernizr.js",
    "postinstall": "node ./node_modules/protractor/bin/webdriver-manager update && npm rebuild node-sass",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.4.6",
    "@angular/common": "^4.4.6",
    "@angular/compiler": "^4.4.6",
    "@angular/core": "^4.4.6",
    "@angular/forms": "^4.4.6",
    "@angular/http": "^4.4.6",
    "@angular/platform-browser": "^4.4.6",
    "@angular/platform-browser-dynamic": "^4.4.6",
    "@angular/router": "^4.4.6",
    "@ngx-translate/core": "6.0.1",
    "@ngx-translate/http-loader": "0.0.3",
    "angular2-datatable": "0.6.0",
    "angular2-jwt": "^0.2.3",
    "angular2-modal": "^3.0.2",
    "angular2-toaster": "3.0.1",
    "auth0-js": "^8.10.1",
    "auth0-lock": "^10.20.0",
    "bootstrap": "3.3.7",
    "chart.js": "2.5.0",
    "classlist.js": "1.1.20150312",
    "core-js": "2.4.1",
    "easy-pie-chart": "2.1.7",
    "flot": "flot/flot#v0.8.3",
    "font-awesome": "4.7.0",
    "intl": "1.2.5",
    "jquery": "3.2.1",
    "jquery-slimscroll": "1.3.8",
    "jquery.browser": "0.1.0",
    "jquery.flot.tooltip": "github:krzysu/flot.tooltip",
    "lodash": "4.17.4",
    "modernizr": "3.5.0",
    "moment": "2.18.1",
    "moment-timezone": "^0.5.13",
    "ng2-charts": "1.6.0",
    "ng2-dnd": "4.0.2",
    "ng2-file-upload": "1.2.1",
    "ng2-nouislider": "^1.6.1",
    "ng2-table": "1.3.2",
    "ng2-validation": "4.1.0",
    "ngx-bootstrap": "1.6.6",
    "ngx-modialog": "^3.0.4",
    "node-sass": "^4.5.3",
    "nouislider": "^10.1.0",
    "rxjs": "^5.5.2",
    "simple-line-icons": "2.4.1",
    "spinkit": "1.2.5",
    "summernote": "0.8.3",
    "sweetalert": "1.1.3",
    "web-animations-js": "2.2.2",
    "whirl": "github:jh3y/whirl",
    "zone.js": "0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.4.9",
    "@angular/compiler-cli": "^4.4.6",
    "@compodoc/compodoc": "^1.0.4",
    "@types/jasmine": "2.5.38",
    "@types/lodash": "4.14.61",
    "@types/moment": "2.13.0",
    "@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",
    "karma-read-json": "1.1.0",
    "loaders.css": "0.1.2",
    "protractor": "5.1.0",
    "ts-node": "2.0.0",
    "tslint": "4.5.0",
    "typescript": ">=2.1.0 <2.4.0",
    "webdriver-manager": "10.2.5"
  }
}

我还想添加一些瀑布的屏幕截图,以便我们可以显示滞后的位置。其中一个屏幕截图显示了外部字体,另外两个屏幕截图显示了对我们 API 的单独调用。一个用于帐户,一个用于联系人。

当我使用独立的东西时,我们的 API 非常快,比如 Google POSTman,或者直接在浏览器中调用它。尽管这些图像可能看起来像是我们的 API,但我只是不买它。我经常使用我们的 API,知道它运行得很快。我正在寻求帮助是缺乏 Angular 的经验。

在来自 Auth0 的回调中找到外部字体

在来自 Auth0 的回调中找到外部字体

调用“我的”帐户路由

调用“我的”帐户路由

调用“联系人”路由

调用“联系人”路由

如果您还有其他需要查看的内容,或者我可以添加以改进这篇文章,请告诉我。我觉得这对于以前经历过这件事的人来说已经足够知道如何提供帮助了。

谢谢!

4

0 回答 0