为什么Angular 2项目如此之大 [英] Why are Angular 2 projects so large

查看:188
本文介绍了为什么Angular 2项目如此之大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在用ng2重写ng1项目.我们的ng1项目建成后约为8mb.重新写入ng2的过程大约只有四分之一,而对于ng2 prod版本,我们已经达到了14mb.

We are in the process of re-writing our ng1 project with ng2. Our ng1 project, when built, is about 8mb. We are about a quarter of the way in our re-write to ng2 and we are already at 14mb for our ng2 prod build.

dist 文件夹大小的主要不同可以归因于源地图大小的不同.这两个项目都包含源地图,但是ng2源地图要大得多.这对我来说很有意义,因为ng2具有更多样板,组件被分离出来,依此类推.

The major difference in the size of the dist folder can be attributed to differing sizes of source maps. Both projects include source maps but ng2 source maps are much larger. This makes sense to me as ng2 has more boilerplate, components are separated out, and so on.

最初,此问题被搁置为 ,因为它太大了,无法回答.我同意.但这正是我要问的原因.我试图弄清楚ng2提供的所有东西,这些东西会使最终的ng2产品比ng1版本更好.

Initially this question was placed on hold as it was too large to answer. I agree. But that's precisely why I am asking it. I'm trying to make sense of all the things ng2 offers that will make the final ng2 product better than the ng1 version.

有了这些,我们可以在ng2开发实践中应用哪些实际方法/程序/工具,以使最终尺寸变小,从而又能更快地获得用户体验?

With that, what are some of the practical approaches/procedures/tools that we can apply to our ng2 development practices to keep final sizes small and in turn user experience fast?

推荐答案

前几天,我尝试使用angular 2,遇到的问题与您相同,我的vendor.js为6M,这是一个简单的"Hello World 应用...

I was trying out angular 2 the other day and I faced the same issue as you do, my vendor.js was 6M and this was a simple "Hello World" app...

我发现以下帖子对理解我们应如何处理此问题有帮助(暂时):

I've found the following post that helped a lot in understanding how we should act on this issue (for now): http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/

他在1.5M应用程序上使用了几种优化和压缩技术(预编译,treeshake,minify,bundle和gzip)将其大小减小到仅50kb.

He uses several optimizing and compression techniques (precompile,treeshake, minify, bundle and gzip) on his 1.5M app to reduce its size to just 50kb.

检查一下,希望对您有所帮助! :)

Check it out, hope it helps! :)

这篇关于为什么Angular 2项目如此之大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆