asp.net-optimization

ASP.NET bundling/minification: including dynamically generated Javascript

三世轮回 提交于 2019-12-01 15:33:27
I have a site that dynamically generates Javascript. The generated code describes type-metadata and some server-side constants so that the clients can easily consume the server's services - so it's very cacheable. The generated Javascript is served by an ASP.NET MVC controller; so it has a Uri; say ~/MyGeneratedJs . I'd like to include this Javascript in a Javascript bundle with other static Javascript files (e.g. jQuery etc): so just like static files I want it to be referenced separately in debug mode and in minified form bundled with the other files in non-debug mode. How can I include

Don't uglify certain file when using Microsoft Web Optimization Framework

耗尽温柔 提交于 2019-12-01 15:15:09
I am trying to concat lots of .js files into a single one using Microsoft Web Optimization framework . Everything works, but within those files I have several that are already minified & uglified and there is not need to process them again. For example I have recaptcha_ajax.js file and it causes following errors when it's appended: /* Minification failed. Returning unminified contents. (715,29-36): run-time error JS1019: Can't have 'break' outside of loop: break t (714,293-300): run-time error JS1019: Can't have 'break' outside of loop: break t (678,210-217): run-time error JS1019: Can't have

ASP.NET bundling/minification: including dynamically generated Javascript

做~自己de王妃 提交于 2019-12-01 14:30:23
问题 I have a site that dynamically generates Javascript. The generated code describes type-metadata and some server-side constants so that the clients can easily consume the server's services - so it's very cacheable. The generated Javascript is served by an ASP.NET MVC controller; so it has a Uri; say ~/MyGeneratedJs . I'd like to include this Javascript in a Javascript bundle with other static Javascript files (e.g. jQuery etc): so just like static files I want it to be referenced separately in

Don't uglify certain file when using Microsoft Web Optimization Framework

南笙酒味 提交于 2019-12-01 14:07:08
问题 I am trying to concat lots of .js files into a single one using Microsoft Web Optimization framework. Everything works, but within those files I have several that are already minified & uglified and there is not need to process them again. For example I have recaptcha_ajax.js file and it causes following errors when it's appended: /* Minification failed. Returning unminified contents. (715,29-36): run-time error JS1019: Can't have 'break' outside of loop: break t (714,293-300): run-time error

Absolute URL in ASP bundle

北城余情 提交于 2019-12-01 02:17:46
I use a jQuery library for Google Maps, and it depends on the Google scripts to be loaded first. I'd like to be able to include both in the bundle as such: bundles.Add(new ScriptBundle("myfoobundle").Include( "http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places", "~/scripts/jquery.fooplugin-{version}.js" )); This doesn't seem to work (throws an exception complaining about the first string). And one may say that this shouldn't work because that absolute URL is not meant to be minified/bundled. But the current approach is a hassle, as I need to ensure that the dependencies are

System.Web.Optimization making function argument names stay the same for certain functions

耗尽温柔 提交于 2019-11-30 21:26:47
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.

Could not load file or assembly 'WebGrease' one of its dependencies. The located assembly's manifest definition does not match the assembly reference

老子叫甜甜 提交于 2019-11-30 17:18:42
This issue has many solutions, please read all answers below, they might help you solve your problem too. If you find a new way to solve this, please document in your answer I am trying to add System.Web.Optimization to my ASP.NET Web Forms solution. I added Microsoft ASP.NET Web Optimization Framework through NuGet Packages. It added Microsoft.Web.Infrastracture and WebGrease (1.5.2) to the references. However, when I run <%= System.Web.Optimization.Scripts.Render("~/bundles/js")%> I get runtime error Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral,

Make ASP.NET bundling specify media=screen for CSS bundle

ⅰ亾dé卋堺 提交于 2019-11-30 10:28:33
问题 I'm just trying out ASP.NET 4.5 bundling and minification, and ran into an issue. I've got around 10 css files, of which 2 were originally referenced in the layout using the attribute media="screen". Since the syntax for adding a css to the bundle does not let you specify that such attribute should be added (makes sense, since the attribute would apply for the whole bundle), I was hoping to see an overload of @Styles.Render that would allow me to specify html attributes, like in other Html

MVC4 Bundle minification doesn't work with javascript reserved words

百般思念 提交于 2019-11-30 08:40:36
Using the latest version of MVC4 I can't minify javascript when it contains reserved words as key names! See the error below with the valid javascript that should have been minified. Does anyone know how to fix this short of rewriting the javascript to use [""] notation? PS The code in question is a few thousand lines long, so it's not an option! /* Minification failed. Returning unminified contents. (3,9-15): run-time warning JS1010: Expected identifier: delete (4,9-13): run-time warning JS1010: Expected identifier: case (5,9-11): run-time warning JS1010: Expected identifier: if (3,9-15): run

System.Web.Optimization making function argument names stay the same for certain functions

寵の児 提交于 2019-11-30 05:40:46
问题 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? 回答1: This isn't something you can change on the built in