AngularJS应用程序最小化保护 [英] AngularJS application minification protection

查看:60
本文介绍了AngularJS应用程序最小化保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题,也许有人可以指导我解决问题.我有一个我要精简的angularjs应用,以获取生产发行版.

I am having a problem that maybe someone can guide me to solve it. I have an angularjs app that I am minifying to get a production distribution.

就像文档说的那样此处使用$ inject关键字来避免依赖注入问题.

Like the documentation says here I can use $inject keyword to avoid Dependency injection problems.

在缩小过程之后,我现在拥有以下

After the minification process, I am now having the following error but since the code was minified I am unable to find out what component (service/directive/etc) I missed to protect against minification.

有没有一种简单的方法可以找出问题的根源?

is there a simple way to find out the source of the problem?

谢谢.

推荐答案

没有简单的方法可以做到这一点.但是,与使用 $ injector 服务相比,解决此特定问题的方法更多.

There's no simple way to do it. However, there are more solutions to this particular problem than using the $injector service.

  • Use ngmin task before minification. It searches for all problematic occurrences and replaces them with minify-friendly code.

执行ngmin手动执行的操作.那就是您有这样声明的地方:

Do what ngmin does manually. That is wherever you have such declaration:

...(函数($ scope,service1){})

替换为

(['$scope', 'service1',
    function ($scope, service1) {})

我们在项目中遇到了同样的问题,因此我们决定使用友好友好的代码(第二种解决方案).尽管今天我可能至少要尝试一下ngmin-现在已经足够稳定了.

We had the same problem in our projects and we decided to go with the minify-friendly code (second solution). Though today I'd probably give ngmin at least a try - it's stable enough now.

这篇关于AngularJS应用程序最小化保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆