Angular 2 Uglify JS 没有被破坏

Angular 2 Uglify JS is not mangled

我试图丑化我的代码,这样我的变量名和函数名就不会出现在生产文件中。

据我所知,Angular CLI (ng build -prod) 没有完成这项工作。所以我尝试了 gulp-uglify。我仍然看到我的大部分函数都有全名:

this.showHeader$=this.showHeaderSource.asObservable()

不适用于 uglify js 演示:http://lisperator.net/uglifyjs/transform

Angular CLI 是 运行 Uglify,但目前 Uglify 不会重命名 Angular 代码中可能有很多(大多数?)的属性。

Original answer 来自 Angular CLI 协作者:

We do run Uglify on your code, but unfortunately Uglify does not rename properties, only function and variable names. A lot of your methods will be properties and not renamed by Uglify. We're looking at solutions but for the time being this is probably not going to change.