Angular 由于 angular 和 firebase 模块,包体积巨大
Angular huge bundle size due to angular and firebase modules
我是 Angular 开发的新手,目前正在研究如何优化 Angular 的包大小。我已经阅读了很多关于包分析器、导入、模块、延迟加载等的帖子。
我的应用程序相当小,但仍会加载 2MB 的供应商包(11MB 未压缩):
我已经将大部分(使用大型第 3 方库的地方)放入延迟加载模块中,但这只节省了几 KB。
最大的模块似乎是:
- angular
- 火力基地
- material
- 时刻
是否可以减小这些模块的大小?
我没有看到任何我导入的地方超过需要的地方。有些部分甚至不是我的。
减少 Angular 应用程序最终构建的一个好习惯是使用 Angular 的提前 (AOT) 编译器。以下是 Angular documentation:
的一些详细信息
Smaller Angular framework download size. There's no need to download the Angular compiler if the app is already compiled. The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.
将 Webpack 集成到您的编译中也很有趣,特别是用于生产构建。 Here's a link to a blog post描述了Angular7和Webpack 4的集成过程
我是 Angular 开发的新手,目前正在研究如何优化 Angular 的包大小。我已经阅读了很多关于包分析器、导入、模块、延迟加载等的帖子。
我的应用程序相当小,但仍会加载 2MB 的供应商包(11MB 未压缩):
我已经将大部分(使用大型第 3 方库的地方)放入延迟加载模块中,但这只节省了几 KB。
最大的模块似乎是:
- angular
- 火力基地
- material
- 时刻
是否可以减小这些模块的大小? 我没有看到任何我导入的地方超过需要的地方。有些部分甚至不是我的。
减少 Angular 应用程序最终构建的一个好习惯是使用 Angular 的提前 (AOT) 编译器。以下是 Angular documentation:
的一些详细信息Smaller Angular framework download size. There's no need to download the Angular compiler if the app is already compiled. The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.
将 Webpack 集成到您的编译中也很有趣,特别是用于生产构建。 Here's a link to a blog post描述了Angular7和Webpack 4的集成过程