System.Web.Optimization决策函数参数的名称保持不变为某些功能 [英] System.Web.Optimization making function argument names stay the same for certain functions

查看:90
本文介绍了System.Web.Optimization决策函数参数的名称保持不变为某些功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP.NET捆绑带ScriptBundle

With ASP.NET Bundling with a ScriptBundle

function StartController($scope, $location, $rootScope) {}

转化为

function StartController(n,t,i) {}

不过因为我使用AngularJs,依赖注入仍然正常,参数名称不得缩小的时候改变。如何确保$范围,$位置和$ rootScope保持这些名称通过一个ScriptBundle的缩小,但允许的说法在其他地方重新命名?

However, as I am using AngularJs, for dependency injection to still work, the argument names must not be changed when minified. How can I ensure $scope, $location and $rootScope keep these names with the minification through a ScriptBundle, but allow argument renaming in other places?

推荐答案

这是不是你可以改变内置捆绑的类型,因为我们目前不公开,你可以在底层的变换类调整旋钮的任何。做到这一点的最好办法是写自己的IBundleTransform这确实缩小传递相应的设置,不能重命名变量。

This isn't something you can change on the built in bundle types, as we currently don't expose any knobs that you can tweak on the underlying transform classes. The best way to accomplish this is to write your own IBundleTransform which does minification passing in the appropriate settings to not rename variables.

即。是这样的:

public class CustomTransform : IBundleTransform {
    public void process(BundleContext context, BundleResponse response) {
         response.Content = MyMinifier.MinifyWithoutRename(response.Content);
    }
}

BundleTable.Bundles.Add(new Bundle("~/bundles/mybundle", new CustomTransform());

这篇关于System.Web.Optimization决策函数参数的名称保持不变为某些功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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