Почему эта страница не работает ... ERR_TOO_MANY_REDIRECTS`? - PullRequest
1 голос
/ 08 июля 2019

Сгенерировал один и тот же файл сценария несколько раз в файле index.html, я недавно обновил проект до версии angular 8.0.2

После обновления угловой версии у меня возникает проблема с репликацией в index.html файле.

Это JavaDemoProject проект Java, я запускаю угловое приложение с этим javaproject с помощью pom.xml файла

Я строю проект с помощью команды maven (mvn clean install -Penv-dev -DskipTests -DbuildNumber=04)

  • pom.xml файл

    <plugin>
        <groupId>com.github.testDemo</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.6</version>
        <configuration>
            <workingDirectory>../Angular-Project</workingDirectory>
            <installDirectory>temp</installDirectory>
        </configuration>
        <executions>
           <!-- It will install nodejs and yarn -->
           <execution>
               <id>install node and yarn</id>
               <goals>
                   <goal>install-node-and-yarn</goal>
               </goals>
               <configuration>
                   <nodeVersion>v11.7.0</nodeVersion>
                   <yarnVersion>v1.9.4</yarnVersion>
               </configuration>
           </execution>
           <!-- It will execute command "yarn install" inside "/angular" 
                directory -->
           <execution>
              <id>yarn install</id>
              <goals>
                 <goal>yarn</goal>
              </goals>
              <configuration>
                   <arguments>install</arguments>
              </configuration>
           </execution>
           <!-- It will execute command "yarn build" inside "/angular" 
               directory to clean and create "/dist" directory -->
           <execution>
               <id>yarn javaDemoprod </id>
               <goals>
                  <goal>yarn</goal>
               </goals>
               <configuration>
                   <arguments>javaDemoprod --outputPath=../JavaDemoProject/
                      src/main/resources/templates/dist</arguments>
               </configuration>
           </execution>
        </executions>
    </plugin>
    
  • tsconfig.json файл:

    {
      "compileOnSave": false,
      "compilerOptions": {
          "baseUrl": "./",
          "module": "commonjs",
          "outDir": "./dist/out-tsc",
          "sourceMap": true,
          "declaration": false,
          "moduleResolution": "node",
          "emitDecoratorMetadata": true,
          "experimentalDecorators": true,
          "target": "es2015",
          "typeRoots": [
             "node_modules/@types"
          ],
          "lib": [
             "es2017",
             "dom"
          ],
          "resolveJsonModule": true,
          "esModuleInterop": true
      }
    }
    
  • Это файл angular.json:

    "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
          "outputPath": "dist/Angular-Project",
          "index": "src/index.html",
          "main": "src/main.ts",
          "polyfills": "src/polyfills.ts",
          "tsConfig": "src/tsconfig.app.json",
          "showCircularDependencies": false,
          "assets": [
            "src/favicon.ico",
            "src/eg.ico",
            "src/assets"
          ],
          "styles": [
            "src/styles.scss"
          ],
          "scripts": [],
          "aot": true
        }
      }
    
  • Package.json

    "dependencies": {
      "@angular/animations": "^8.0.1",
      "@angular/cdk": "^8.0.1",
      "@angular/common": "^8.0.1",
      "@angular/compiler": "^8.0.1",
      "@angular/core": "^8.0.1",
      "@angular/forms": "^8.0.1",
      "@angular/material": "^8.0.1",
      "@angular/platform-browser": "^8.0.0",
      "@angular/platform-browser-dynamic": "^8.0.1",
      "@angular/router": "^8.0.1",
      "core-js": "^2.5.4",
      "hammerjs": "^2.0.8",
      "ngx-loading": "^3.0.1",
      "node-sass": "^4.10.0",
      "rxjs": "6.5.2",
      "underscore": "^1.9.1",
      "zone.js": "~0.9.1"
    },
    "devDependencies": {
      "@angular-devkit/build-angular": "~0.800.0",
      "@angular/cli": "~8.0.2",
      "@angular/compiler-cli": "^8.0.1",
      "@angular/language-service": "^8.0.1",
      "@types/jasmine": "~2.8.6",
      "@types/jasminewd2": "~2.0.3",
      "@types/node": "~8.9.4",
      "bootstrap-sass": "^3.3.7",
      "codelyzer": "^5.0.1",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~1.7.1",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.0",
      "karma-jasmine": "~1.1.1",
      "karma-jasmine-html-reporter": "^0.2.2",
      "karma-scss-preprocessor": "^3.0.0",
      "protractor": "~5.3.0",
      "ts-node": "~5.0.1",
      "tslint": "~5.9.1",
      "typescript": "~3.4.5"
    }
    

После сборки приложения в index.html пути к файл JavaDemoProject\src\main\resources\templates\dist\index.html получаю эту репликацию script файлов, как я могу предотвратить эту репликацию script файлов.

<body>
    <app-root></app-root>
    <script src="runtime-es2015.js" type="module"></script>
    <script src="polyfills-es2015.js" type="module"></script>
    <script src="runtime-es5.js" nomodule></script>
    <script src="polyfills-es5.js" nomodule></script>
    <script src="styles-es2015.js" type="module"></script>
    <script src="styles-es5.js" nomodule></script>
    <script src="vendor-es2015.js" type="module"></script>
    <script src="main-es2015.js" type="module"></script>
    <script src="vendor-es5.js" nomodule></script>
    <script src="main-es5.js" nomodule></script>
</body>

Эта репликация файла скрипта получает вывод приложения, показывающего

This page isn't working...
ERR_TOO_MANY_REDIRECTS

Может кто-нибудь помочь мне решить эту проблему. Заранее спасибо.

1 Ответ

0 голосов
/ 08 июля 2019

Сценарии, которые вы можете видеть, из-за функции дифференциальной загрузки.Angular 8 имеет новую функцию для генерации отдельного пакета для более старого браузера и новых браузеров.Вы можете контролировать, какой браузер вы хотите поддерживать, вы можете узнать больше об этой функции на https://angular.io/guide/deployment#differential-loading

...