bundling-and-minification

Asp.Net MVC4 Bundling & Minification .min.js files excluded from Scripts.Render?

穿精又带淫゛_ 提交于 2019-11-29 14:47:28
问题 I created some theme HtmlHelper extensions for that grab the .css and .js files in a theme directory and dynamically register them as bundles. However, if the theme only contains .min.js files, the Scripts.Render output is empty in debug mode. Is there a way to include *.min.js files in the output for Scripts.Render when in debug mode? 回答1: Figured it out. BundleTable.Bundles.IgnoreList.Clear(); // apparently, IgnoreList included .min.js in debug BundleTable.Bundles.IgnoreList.Ignore("

Is it possible to unit test BundleConfig in MVC4?

£可爱£侵袭症+ 提交于 2019-11-29 13:38:49
As far as I can tell, the answer is no. The issue I'm seeing comes from the Include(params string[]) method in the System.Web.Optimization.Bundle class. Internally this invokes System.Web.Optimization.IncludeDirectory(string, string, bool) , which in turn uses this code: DirectoryInfo directoryInfo = new DirectoryInfo( HttpContext.Current.Server.MapPath(directoryVirtualPath)); While it is possible to set HttpContext.Current during a unit test, I can't figure out how to make its .Server.MapPath(string directoryVirtualPath) return a non-null string. Since the DirectoryInfo(string) constructor

MVC4 Bundle minification doesn't work with javascript reserved words

痞子三分冷 提交于 2019-11-29 12:16:58
问题 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

CSS changes on MVC App not working

一笑奈何 提交于 2019-11-29 07:29:43
I created an MVC app using VS Express for web. It it will only use the default built in CSS file that VS Express comes with. Example: If I modify the bootstrap.css file (change jumbotron color), and run locally from VS, the changes are apparent, however when i web deploy, none of those changes are apparent. I also noticed when I modify the web.config file to Debug=false, the CSS changes I've made are not apparent when I run it locally from VS (and on web deploy). CSS is still being applied, however any changes I make are not applied. The site shows the old default jumbotron color. If I change

How do I add type=“text/javascript” to a script tag when using System.Web.Optimization

狂风中的少年 提交于 2019-11-29 06:52:30
I have the following bundles.Add(new ScriptBundle("~/bundles/scripts/common").Include( "~/Scripts/jquery.validationEngine.js", "~/Scripts/common.js")); Which generates <script src="/bundles/scripts/common?v=9O0Yi3fV_GWpGyJQ_QYURiOYy6SEmxUQtkUVN4GXo2U1"></script> When rendered with <asp:PlaceHolder ID="PlaceHolderJs" runat="server"> <%: Scripts.Render("~/bundles/scripts/common") %> </asp:PlaceHolder> Which is not valid HTML as its missing type="text/javascript". How do I make the BundleCollection output this element in the script tag? MikeSmithDev One way is to change how you render your

Bundling not working in MVC5 when I turn on release mode

浪子不回头ぞ 提交于 2019-11-29 04:55:19
问题 I have the following bundle configured in BundleConfig.cs: bundles.Add(new StyleBundle("~/bundles/css").Include( "~/assets/bootstrap/css/bootstrap.css", "~/assets/css/global/all.css")); and I reference it using the following: @Styles.Render("~/bundles/css") When I'm in debug mode (web.config compilation debug="true" ) it works as expected in that it renders both css files as normal ie: <link href="/assets/bootstrap/css/bootstrap.css" rel="stylesheet"/> <link href="/assets/css/global/all.css"

MVC4 bundling/minification with IE conditional comments

僤鯓⒐⒋嵵緔 提交于 2019-11-29 02:41:16
问题 I am trying to use MVC4's new "bundling and minification". For IE conditional comments, I'm still doing it the old way: <!--[if lt IE 9]><link href=.../><![endif]--> or <!--[if lt IE 9]>@Styles.Render("~/foo")<![endif]--> but I don't seem to get the automatic debug/release handling. Is there a built-in way to do this? How are others doing this? EDIT: Also it would be great to be able to include <noscript> tags inside the rendered output (used for fallbacks). 回答1: Until I find a better way, I

How do I configure MVC's style bundling order?

早过忘川 提交于 2019-11-29 02:29:42
问题 My web app is using a large icon set with jquery-ui and jqgrid. In order to easily maintain the changes to the CSS to accommodate the larger icons when upgrading jquery-ui or jqgrid I have a separate CSS file where I have a bunch of overrides. As you can imagine this override file MUST be included after the jquery-ui stylesheet and the jqgrid style sheet. I put all my stylesheets into a bundle like so bundles.Add(new StyleBundle("~/Content/dark-hive/allstyles").Include( "~/Content/dark-hive

ASP.Net MVC Style Bundle Not Including Most Files

对着背影说爱祢 提交于 2019-11-29 02:18:37
问题 Recently, my local copy of a project completely lost most of its styling. Took me a while to figure it out, as most of the styling was done in one file and the rest were minor things like Kendo and jQuery UI. The other, minor stuff wasn't being added to the page. I thought the styles had been modified by another developer (haven't touched this project in a while) who was only testing the Web API stuff and not the UI so he could have wrecked it and never known, but I tracked down the problem:

Bundling and minification without ASP.NET MVC

若如初见. 提交于 2019-11-28 18:19:17
Is it possible to use bundling and minification from Microsoft.AspNet.Web.Optimization without having an MVC project? I'm creating an AngularJS site communicating with a REST API. For the REST API I'm using ASP.NET Web API. I have also created an "ASP.NET Empty Web Application". There are only HTML, js and CSS files in this project (and a web.config). I'd like for my js and CSS files to be bundled and minified, but I don't want to create a MVC project just to get that. Is it possible? It is absolutely possible to use the bundling and minification in a blank project. Use Nuget to install the