First off the new bundling and minification look nice. I have done this in the past a few times, so it will be nice to have it built in. Howerver, I think there is a feature that is missing. The ability to toggle it on and off, perhaps in a web.config
So here is why, when I am developing, on my machine I want to see each js and css file. If I just put a bug into a js file (which I of course, never do:) it is much easier to find out where it is if all the files are seperate, and not minimized. I don't
want to have to change any views or anything, I want to be able to control it in a web config, so if there is an issue found after the project has been deployed somewhere, you cna still turn it off and debug.
I don't really see how that would work. When you use bundling and minification, you do something like "~/Scripts/js". If you turn it off, then there is no longer any bundling, and the bundle will fail.
You would need to alter your views in order to include the actual javascript files, otherwise how else will the browser be able to request them? Remember, javascript debugging happens on the browser, and in order for the browser to see the file as an individual
file, it has to request it as an individual file, and it can't do that if you don't have an individual script tag for it.
What you CAN do is create a "custom" bundle as a subdirectory of your Scripts folder. Then, when you are working on a script, you can move it to the custom folder have it only "bundle" a single file without minification. Something like this:
Bundle debugScripts = new Bundle("~/DebugScripts", new NoTransform("text/javascript"));
debugScripts.AddDirectory("~/Scripts/Debug", "*.js");
BundleTable.Bundles.Add(debugScripts);
Then just include a script tag for the debug bundle, and it will just 404 when you're not doing anything.
Marked as answer by ricka6 on Mar 01, 2012 07:45 PM
Might look into RequestReduce. It has allows you to turn minification and bundling on and off via a config setting. What is also handy is that even with it turned on, at runtime you can append any url with the querystring
pair rrfilter=disabled and the bundling and minification gets turned off for that request alone, which is nice for debugging in production or even dev. RequestReduce does not require you to change your views to declare bundles, it just figures out what the
bundles should be by looking at your markup at runtime and injecting bundled and minified content automatically. All generated bundles are cached and the actual bundling/minification is done in the background and does not impact runtime perf.
Marked as answer by ricka6 on Feb 27, 2012 10:43 PM
has NoTransform been renamed or removed in the RC? Cant seem to find it.
It is a custom Transform. BTW, in RC (and possibly in coming RTM,) you can set debug="true" to turn off bundling/minification or you can use BundleTable.EnableOptimizations
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Pinger
Member
45 Points
10 Posts
Bundling and Minification Toggle
Feb 24, 2012 05:10 PM|LINK
First off the new bundling and minification look nice. I have done this in the past a few times, so it will be nice to have it built in. Howerver, I think there is a feature that is missing. The ability to toggle it on and off, perhaps in a web.config
So here is why, when I am developing, on my machine I want to see each js and css file. If I just put a bug into a js file (which I of course, never do:) it is much easier to find out where it is if all the files are seperate, and not minimized. I don't want to have to change any views or anything, I want to be able to control it in a web config, so if there is an issue found after the project has been deployed somewhere, you cna still turn it off and debug.
worldspawn[]
Contributor
6081 Points
1336 Posts
Re: Bundling and Minification Toggle
Feb 25, 2012 05:07 AM|LINK
Give Cassette.Net a try.
http://getcassette.net/
http://getcassette.net/documentation/configuration
"Wise man say 'forgiveness is divine, but never pay full price for late pizza." - TMNT
software development
mystere
Member
395 Points
90 Posts
Re: Bundling and Minification Toggle
Feb 26, 2012 04:02 AM|LINK
I don't really see how that would work. When you use bundling and minification, you do something like "~/Scripts/js". If you turn it off, then there is no longer any bundling, and the bundle will fail.
You would need to alter your views in order to include the actual javascript files, otherwise how else will the browser be able to request them? Remember, javascript debugging happens on the browser, and in order for the browser to see the file as an individual file, it has to request it as an individual file, and it can't do that if you don't have an individual script tag for it.
What you CAN do is create a "custom" bundle as a subdirectory of your Scripts folder. Then, when you are working on a script, you can move it to the custom folder have it only "bundle" a single file without minification. Something like this:
Bundle debugScripts = new Bundle("~/DebugScripts", new NoTransform("text/javascript")); debugScripts.AddDirectory("~/Scripts/Debug", "*.js"); BundleTable.Bundles.Add(debugScripts);Then just include a script tag for the debug bundle, and it will just 404 when you're not doing anything.
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Bundling and Minification Toggle
Feb 26, 2012 04:45 PM|LINK
I agree. I'll look into this.
matt wrock
Member
44 Points
2 Posts
Re: Bundling and Minification Toggle
Feb 27, 2012 07:17 PM|LINK
Might look into RequestReduce. It has allows you to turn minification and bundling on and off via a config setting. What is also handy is that even with it turned on, at runtime you can append any url with the querystring pair rrfilter=disabled and the bundling and minification gets turned off for that request alone, which is nice for debugging in production or even dev. RequestReduce does not require you to change your views to declare bundles, it just figures out what the bundles should be by looking at your markup at runtime and injecting bundled and minified content automatically. All generated bundles are cached and the actual bundling/minification is done in the background and does not impact runtime perf.
markfalto
Member
2 Points
1 Post
Re: Bundling and Minification Toggle
Jul 24, 2012 08:59 PM|LINK
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Bundling and Minification Toggle
Aug 05, 2012 03:14 PM|LINK
It is a custom Transform. BTW, in RC (and possibly in coming RTM,) you can set debug="true" to turn off bundling/minification or you can use BundleTable.EnableOptimizations
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD