【发布时间】:2019-04-05 05:45:50
【问题描述】:
有没有办法混淆 Angular 6(或 7)应用程序的生产代码。生产代码是指在命令 ng build --prod 之后生成的 dist 文件夹。 我见过一个名为 Jscrambler 的软件,但它不是免费的。 我该怎么做?
谢谢
【问题讨论】:
标签: angular security angular6 obfuscation angular7
有没有办法混淆 Angular 6(或 7)应用程序的生产代码。生产代码是指在命令 ng build --prod 之后生成的 dist 文件夹。 我见过一个名为 Jscrambler 的软件,但它不是免费的。 我该怎么做?
谢谢
【问题讨论】:
标签: angular security angular6 obfuscation angular7
如果你有 Angular 7+,你可以使用@angular-builders/custom-webpack 来使用javascript-obfuscator。请注意,我为 Angular 8+ 链接了 custom-webpack,假设您可能在一年前进行了升级。如果您需要 Angular 7 版本,他们在该页面上有指向 Angular 7 兼容版本 @angular-builders/custom-webpack 的链接
【讨论】:
当您使用 Angular CLI 构建生产代码时,您的代码已经被缩小和丑化(由 UglifyJS),如 Angular doc 中所述
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.
如果您没有收到代码混淆,您可能需要检查您的 angular.json 文件并确保它包含以下设置:
"configurations": {
"production": {
"optimization": true,
【讨论】: