自定义.NET 4.5捆扎机/ minifier [英] Customizing .NET 4.5 bundler/minifier

查看:188
本文介绍了自定义.NET 4.5捆扎机/ minifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以自定义的JavaScript mi​​nfier /捆扎机随.NET 4.5(Microsoft.Web.Optimization)各种微小选项的输出?例如,我想允许本地变量重命名,但不允许函数参数重命名。

Is there a way to customize the output of the JavaScript minfier/bundler that comes with .NET 4.5 (Microsoft.Web.Optimization) with various minification options? For example, I want to allow local variable renaming but not allow function argument renaming.

作为背景,我想引入一个AngularJS应用程序到.NET应用程序,并希望能够利用捆绑/缩小框架自带.NET 4.5。我不希望函数参数重命名为发生,因为AngularJS使用的参数名做依赖注入。

As a background, I'm trying to introduce an AngularJS app into a .NET application, and want to be able to use the bundling/minification framework that comes with .NET 4.5. I don't want function argument renaming to happen since AngularJS uses the argument names for doing dependency injection.

推荐答案

AngularJs已经可以建立时如何处理,对于您通过 [] 语法选项控制器或其它角度服务

AngularJs already can handle that for you via the [] syntax option when building up controllers or other angular services

app.controller("MyCtrl", function($scope, $http){});

变为

app.controller("MyCtrl", ["$scope", "$http", function($scope, $http){
}];

,或通过 $注

var myCtrl = function($scope, $http){};

myCtrl.$inject = ['$scope', '$http'];

这样做可以让角要知道即使在JS被缩小的注入哪件。

Doing this allows Angular to know which pieces to inject even when the js is minified.

这篇关于自定义.NET 4.5捆扎机/ minifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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