Angular 6 迁移延迟加载问题

Angular 6 migration Lazy loading issue

我正在将我的应用程序从 Angular 5 迁移到 angular 6。一切正常,除了延迟加载的模块。当我 运行 应用程序

时出现以下错误

尽管如此,我的应用程序 运行 与 angular 5 没问题。我所有的 js 路径都是这样的

<script type="text/javascript" src="http://localhost:4200/dist/polyfills.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/scripts.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/styles.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/vendor.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/main.js"></script>

那为什么它从主域加载延迟加载模块URL?喜欢 localscorm?

我的 package.json 文件是

"scripts": {
    "ng": "ng",
    "start": "ng serve --deploy-url http://localhost:4300/dist/ --serve-path /dist/ --public-host http://localhost:4300",
    "build": "ng build",
    "build:prod": "ng build --prod --base-href ./",
    "build:webprod": "ng build --prod --output-path ../dist --deploy-url ../dist/",
    "build:webstaging": "ng build --env=staging --prod --output-path ../dist --deploy-url ../dist/",
    "test": "ng test",
    "lint": "ng lint",


    "watch:tsc": "tsc -p src/tsconfig.app.system.json -w",
    "html": "copyfiles -u 1 src/app/**/*.html src/app/**/*.css ../dist/",
    "assets": "copyfiles -u 1 src/assets/**/* ../dist/",
    "watch:global:static": "npm run assets",
    "watch:app:static": "npm run html",
    "watch": "npm-watch",
          },

如何解决这个加载块问题?

目前延迟加载模块和 Angular6 似乎存在问题。 看到这个 Github thread.

一些用户的解决方法似乎是

ng serve --aot

修复Angular6中的问题,在angular.json

中添加如下配置
"serve": {
   "builder": "@angular-devkit/build-angular:dev-server",
   "options": {
   "browserTarget": "scorm-app:build:local",
   "port": 4300,
   "servePath": "/dist/",
   "publicHost": "http://localhost:4300"
}

其中 "browserTarget": "scorm-app:build:local",指向本地环境的配置。