Angular 8构建不适用于IE,尽管服务正常 [英] Angular 8 build does not work with IE though serve works fine
问题描述
im尝试为ie构建我的angular 8应用程序,但是它不起作用.
im tried to build my angular 8 app for ie, but it does not work.
我遵循了一些教程和解决方法来修复"它.
遗憾的是,它仅适用于 ng服务
,不适用于 ng buld
/ ng build --prod
.
I followed several tutorials and workarounds how to "fix it".
Sadly it only works for ng serve
and not for ng buld
/ ng build --prod
.
我使用的来源:
- Stackoverflow-我如何支持互联网Angular 8应用程序中的资源管理器?
- 角度指南-浏览器支持
-
请注意,这仅适用于开发服务器:
ng服务器
,不适用于生产版本现在我不确定问题出在哪里或在哪里进一步解决.
Now i'm not sure what the problem is or where to look further.
tsconfig.json
tsconfig.json
{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, "module": "esnext", "moduleResolution": "node", "importHelpers": true, "target": "es2015", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2018", "dom" ] }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true } }
tsconfig.es5.json
tsconfig.es5.json
{ "extends": "./tsconfig.json", "compilerOptions": { "target": "es5" } }
angular.json
angular.json
... build": { "builder": "@angular-devkit/build-angular:browser", ... "configurations": { "es5": { "tsConfig": "./tsconfig.es5.json" }, ... "serve": { "builder": "@angular-devkit/build-angular:dev-server", ... "configurations": { "es5": { "browserTarget": "my-project:build:es5" },
浏览器列表
> 0.5% last 2 versions Firefox ESR not dead IE 9-11 # For IE 9-11 support, remove 'not'.
对于每个想要最小的,可复制的示例的人,当我只是使用Angular创建一个干净的新项目时Cli 8.3.9和Angular:8.2.11就像这样
For every one who want a minimal, reproducible example, when i just create a clean new project with Angular Cli 8.3.9 and Angular: 8.2.11 like this
我在chrome 77和Internet Explorer 11中得到以下输出
I get the following output in chrome 77 and internet explorer 11
请注意,当我运行
ng服务器
时,它也将在ie 11Note when i run
ng server
it also runs in ie 11推荐答案
我遇到了类似的问题.
在我的案例中,IE 11抱怨:
in my case IE 11 complains:
SCRIPT1002: Syntax error in scripts.22d9f1b41174f0698a97.js (1,221172) - pointing to class s{constructor(t,e,n,i)...
看起来好像minifier创建了不兼容的IE JS代码,我的设置是:
it looks like the minifier creates incompatible IE JS code, my set up is:
浏览器列表:
> 0.5% last 2 versions Firefox ESR dead IE 9-11 # For IE 9-11 support, remove 'not'.
tsconfig:
"compilerOptions": { "downlevelIteration": true, "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2018", "dom" ], "module": "esnext", "baseUrl": "./" }
env:
Angular CLI: 8.3.23 Node: 10.9.0 OS: win32 x64 Angular: 8.2.14
我也尝试了目标:2015(和差异加载),但是它产生了更多的错误:/
i also tried with target: 2015 (and differential loading) but it generated even more errors :/
这篇关于Angular 8构建不适用于IE,尽管服务正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!