我遇到了问题,也许有人可以指导我解决问题.我有一个我要精简的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.
-
在缩小之前使用 ngmin任务.它会搜索所有出现问题的地方,并用友好的最小化代码替换它们.
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应用程序最小化保护
发布评论