AngularJS应用程序最小化保护

编程入门 行业动态 更新时间:2024-10-25 06:22:16
本文介绍了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.

  • 在缩小之前使用 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应用程序最小化保护

本文发布于:2023-11-04 05:20:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557054.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最小化   应用程序   AngularJS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!