1

我有一个 Angular 6 的应用程序,我需要它在 IE10 和 IE11 中工作,我正在按照 angular web 指示进行配置,但是当我运行“ng build --prod”时,我无法让它在 IE 中工作(使用命令“ng serve”不,我有问题)。

polyfills 文件放置与 IE 相关的所有内容

通过删除 prod 构建配置的选项“优化”并将文件夹“./node_modules/core-js/”放在 dist 根目录中,使其工作。

我需要在不删除此选项的情况下解决问题。这是可能的?

我留下文件 angular.json、polyfills.ts 和 package.json

包.json

{
  "name": "sro",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "build-develop": "ng build --base-href=/APP/ --configuration=develop",
    "build-testing": "ng build --base-href=/APP/ --configuration=testing",
    "build-prod": "ng build --base-href=/APP/ --configuration=prod",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.8",
    "@angular/common": "^6.1.8",
    "@angular/compiler": "^6.1.8",
    "@angular/core": "^6.1.8",
    "@angular/forms": "^6.1.8",
    "@angular/http": "^6.1.8",
    "@angular/platform-browser": "^6.1.8",
    "@angular/platform-browser-dynamic": "^6.1.8",
    "@angular/router": "^6.1.8",
    "@ng-bootstrap/ng-bootstrap": "^3.2.0",
    "core-js": "^2.5.4",
    "ngx-captcha": "^3.1.2",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.3",
    "@angular/cli": "^6.2.3",
    "@angular/compiler-cli": "^6.1.8",
    "@angular/language-service": "^6.1.8",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.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": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ngx-spec": "^1.0.1",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.9.2"
  }
}

角.json

        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/app",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "prod": {
              "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
            }

在 polyfills.ts 中取消注释此行:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js';  // Run `npm install --save classlist.js`.

/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
4

0 回答 0