通过隐藏/混淆代码来保护Angular 6/7应用程序

You*_*ati 7 security obfuscation angular angular6 angular7

有没有一种方法可以混淆AnAngular 6(或7)应用程序的生产代码。生产代码是指在ng build --prod命令之后生成的dist文件夹。我见过一个名为Jscrambler的软件,但它不是免费的。我怎样才能做到这一点 ?

谢谢

小智 4

当您使用 Angular CLI 构建生产代码时,您的代码已经被缩小和丑化(由 UglifyJS),如Angular 文档中所述

The --prod meta-flag engages the following build optimization features.

 - Ahead-of-Time (AOT) Compilation: pre-compiles Angular component templates.
 - Production mode: deploys the production environment which enables production mode.
 - Bundling: concatenates your many application and library files into a few bundles.
 - Minification: removes excess whitespace, comments, and optional tokens.
 - Uglification: rewrites code to use short, cryptic variable and function names.
 - Dead code elimination: removes unreferenced modules and much unused code.
Run Code Online (Sandbox Code Playgroud)

如果您没有遇到代码混淆,您可能需要检查您的angular.json文件并确保它包含以下设置:

"configurations": {
  "production": {
    "optimization": true,
Run Code Online (Sandbox Code Playgroud)