With ASP.NET Bundling with a ScriptBundle
function StartController($scope, $location, $rootScope) {}
is transformed to
function StartController(n,t,i) {}
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?
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.
I.e. something like:
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With