为什么文件夹 dist (-prod) 中的 angular-cli webpack 有 gzip 文件也没有 gzip 文件

Why angular-cli webpack in folder dist (-prod) has gzip files as well as not gzip files

我对 Angular-cli 结构很感兴趣。当我构建 prod 时,(ng build -prod) 我得到了文件夹 dist,在那里我找到了相同的文件,其中一个是 gzip,另一个不是。

结构文件夹 /dist:

我是否需要 gzip 文件?或者也许我不需要 gzip 而不是 JS 文件。为什么我必须持有两份文件?

我的文件夹因此变得更重了。你能给我解释一下这是怎么回事吗?

Update

Gzip generation has been removed the Angular CLI because it was confusing to many people, and now the CLI only outputs the files you actually use.

For more information, check out the official ng build documentation.

存在 gz 文件,因此您可以检查 js 文件在发送到浏览器时的实际大小。因为您几乎肯定会在服务器上使用 GZIP。

您可以通过添加 --suppress-sizes true 来跳过生成它们。

这将删除其中的大部分。有一个错误使它仍然留下一个 gz,您仍然可以通过添加 --vendor-chunk false.

来解决这个问题

您可以看到更多优化并从 my comment on this issue in the Angular CLI repository 获取上下文。