And*_*oth 5 asp.net-mvc asp.net-optimization
使用ASP.NET捆绑ScriptBundle
function StartController($scope, $location, $rootScope) {}
Run Code Online (Sandbox Code Playgroud)
变成了
function StartController(n,t,i) {}
Run Code Online (Sandbox Code Playgroud)
但是,由于我使用的是AngularJs,因为依赖注入仍然有效,因此在缩小时不得更改参数名称.我怎样才能确保$ scope,$ location和$ rootScope通过ScriptBundle保持这些名称的缩小,但是允许在其他地方重命名参数?
这不是您可以在内置捆绑类型上更改的内容,因为我们目前没有公开任何您可以在底层转换类上调整的旋钮。实现此目的的最佳方法是编写自己的 IBundleTransform,它会在适当的设置中进行缩小传递,以免重命名变量。
即类似:
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());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1802 次 |
| 最近记录: |