【问题标题】:Angular compilation slow角度编译慢
【发布时间】:2020-01-29 13:15:10
【问题描述】:

我在 Symfony-PHP 中有一个 API,我用 postman 对其进行了测试,它的工作原理就像一个魅力。但是当我执行ng serve --aot --optimization 时,应用程序开始构建,compiled successfully. 的消息需要一分钟多的时间。 当我需要对一个html 组件(例如一个字母)进行更改时,它会重新编译整个项目,并且对于这样一个小改动需要太长时间。

--watch参数默认设置为true,就可以了。不知道有没有人知道这个编译为什么这么慢。

版本:

Angular CLI: 6.2.2
Node: 8.12.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.8.2
@angular-devkit/core         0.8.2
@angular-devkit/schematics   0.8.2
@schematics/angular          0.8.2
@schematics/update           0.8.2
rxjs                         6.2.2
typescript                   2.9.2


oscar@ubuntu:~$: ng s --aot --optimization


****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.

DON'T USE IT FOR PRODUCTION!
****************************************************************************************
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
 10% building modules 7/8 modules 1 active ...s\orquestados-front-user\src\styles.cssBrowserslist: caniuse-lite is outdated. Please run next command `n 70% building modules 646/646 modules 0 activei 「wdm」: wait until bundle finished: /pages/offer/management/219702                                             92% chunk asset optimization TerserPlugini 「wdm」: wait until bundle finished: /pages/offer/management/219702
i 「wdm」: wait until bundle finished: /pages/offer/management/219702
Date: 2019-09-30T08:30:18.736Z
Hash: 9afdb6037df5643d0cb2
Time: 512136ms
chunk {0} runtime.js, runtime.js.map (runtime) 1.45 kB [entry] [rendered]
chunk {1} main.js, main.js.map (main) 2.3 MB [initial] [rendered]
chunk {2} polyfills.js, polyfills.js.map (polyfills) 62 kB [initial] [rendered]
chunk {3} styles.js, styles.js.map (styles) 45.6 kB [initial] [rendered]
chunk {4} vendor.js, vendor.js.map (vendor) 1020 kB [initial] [rendered]
i 「wdm」: Compiled successfully.

【问题讨论】:

标签: node.js angular angular-cli


【解决方案1】:

省略--optimization。然后,基于变化的构建将花费更少的时间。也尝试不使用--aot。第一次构建总是需要一些时间。但是增量构建只需要几秒钟。

【讨论】:

  • 应该有点快。但只是没有那么快。 --optimization 仅用于生产版本。
  • 唯一的问题是网站比以前慢了。为什么会这样?
  • 没有--aot,模板是在浏览器中构建的。
  • 我发现最好让 --aot 接受较慢的构建时间,而不是在浏览器中接受构建模板并处理缓慢的加载(我的大型 SPA 应用程序需要 37 秒)。
猜你喜欢
  • 2016-01-16
  • 2018-10-02
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 1970-01-01
  • 2018-12-04
相关资源
最近更新 更多