首页 > 解决方案 > 与以前版本的 Angular 5/6/7 相比,在 Angular 8 中为 ng 构建生成的文件不同

问题描述

这是我第一次研究 Angular Web 组件。我尝试了许多在线教程甚至视频教程,我看到教程中讨论的示例是 angular 5/6/7 版本,但找不到 angular 8 的示例或教程。

就像npm run build在 Angular 5/6/7 版本中一样,它会生成以下文件:

"./dist/my-app/runtime.js",
"./dist/my-app/polyfills.js",
"./dist/my-app/scripts.js",
"./dist/my-app/main.js"

但在 Angular 8 中,它会生成以下文件:

"./dist/my-app/runtime-es2015.js",
"./dist/my-app/runtime-es2015.js",
"./dist/my-app/polyfills-es2015.js",
"./dist/my-app/polyfills-es5.js",
"./dist/my-app/scripts.js",
"./dist/my-app/main-es5.js"
"./dist/my-app/main-es2015.js"

我尝试了这些教程 Web Components with angular

使用 Angular 的 Web 组件——你确定吗?

我被困在这部分

创建一个脚本以将我们的 Web 组件作为单个文件弹出

因为文件不匹配

标签: angular

解决方案


这是由于不同的负载。Angular 8 中引入的一项新功能,用于在所有浏览器中加载应用程序。在 Angular 8 中,文件浏览器列表必须位于项目根文件夹中。项目需要以下条目来禁用差异加载,这有助于匹配文件

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11
not samsung 4
not android 4.4.3-4.4.4
not last 2 ie_mob versions
not last 2 op_mini versions
not last 2 op_mob versions
not last 2 baidu versions
not last 2 kaios versions
not last 2 and_uc versions
not last 2 and_qq versions
not last 2 edge versions
not chrome 49

推荐阅读