bundling-and-minification

How can we enable caching for Bundles in MVC5

不羁岁月 提交于 2019-12-31 04:05:09
问题 I have created 2 bundles in my mvc project as given below: public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/Scripts/BaseScripts").Include( "~/Content/js/jquery-{version}.js", "~/Content/js/jquery-ui-{version}.js", "~/Scripts/jquery.unobtrusive-ajax.min.js", "~/Content/js/bootstrap.js", "~/Content/js/bootstrap-datepicker.js", "~/Scripts/jquery.validate.min.js", "~/Scripts/jquery.validate.unobtrusive.js", "~/Scripts/customvalidation.js" ) ); bundles

How do I use ASP.NET bundling and minification without recompiling?

混江龙づ霸主 提交于 2019-12-31 02:17:25
问题 Constraints: I'm not using MVC, just regular ol' .aspx files in my web app. Not using master pages either - each page is a different beast, so that solution isn't right for me. Most examples I've read for bundling and minification require either some special MVC markup or require you to identify the bundled scripts / stylesheets up front and then refer to these bundles. I want to avoid recompiling DLLs every time I add or modify a .js reference in a .aspx page. I'm a bit stumped from reading

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

拥有回忆 提交于 2019-12-30 05:44:28
问题 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

Is it possible to unit test BundleConfig in MVC4?

瘦欲@ 提交于 2019-12-29 08:30:11
问题 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

CSS changes on MVC App not working

妖精的绣舞 提交于 2019-12-29 07:04:11
问题 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,

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

让人想犯罪 __ 提交于 2019-12-29 06:51:29
问题 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

asp.net mvc exclude css file from bundle

大城市里の小女人 提交于 2019-12-28 06:27:18
问题 I have such bundle bundles.Add(new StyleBundle("~/Content/themes/default/css") .IncludeDirectory("~/Content/themes/Default", "*.css")); but I want to exclude one CSS file from it. Is it possible to make this without specifying each CSS file in bundle? 回答1: Try using IgnoreList.Ignore; bundles.IgnoreList.Ignore(...) . 回答2: An extension method could be what you need here: public static class BundleExtentions { public static Bundle IncludeDirectoryWithExclusion(this StyleBundle bundle, string

Bundling scripts are not getting rendered

為{幸葍}努か 提交于 2019-12-28 04:31:05
问题 I am having a problem with script bundling and minification with ASP .NET I have tried all popular solution found on internet but still having the same problem. My BundleConfig.cs looks like namespace MYPROJ{ public class BundleConfig { public static void AddDefaultIgnorePatterns(IgnoreList ignoreList) { if (ignoreList == null) return; ignoreList.Ignore("*.intellisense.js"); ignoreList.Ignore("*-vsdoc.js"); ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled); ignoreList.Ignore("*

ASP.NET Bundling - Bundle not updating after included file has changed (returns 304 not modified)

假如想象 提交于 2019-12-28 03:31:06
问题 I am trying out ASP.NET Bundling with ASP.NET MVC 4 application. The situation is that I want to make a CDN style service, which has JS and CSS files to which you can address from other sites with this type address: http://www.mycdn.com/scripts/plugin/js, which bundles and minifies all included .js files. My bundle config for one file looks like this: bundles.Add(new ScriptBundle("~/Scripts/plugin/pluginjs").Include("~/Scripts/plugin/jquery.plugin.js")); However, when I do this, the bundles

How to run TypeScript in Visual Studio 2015 without require() or requireJS

自古美人都是妖i 提交于 2019-12-24 09:18:58
问题 I've setup a new web project where I wanted to begin working/learning TypeScript. This project while an empty c#.net web project is not using MVC, angular, etc. It is just plain vanilla html and Ts. Everything was running smooth until I started setting up modules (classes, interfaces etc.) Once I started exporting and importing the modules I began receiving in the dev tools the error Uncaught ReferenceError: require is not defined . Looking at the actual js file I can see it is wrapping the