Reputation: 34038
I know that bundling and minification only works when not in debug mode.
<compilation debug="false" targetFramework="4.5"/>
If I press Ctrl + F5 to run my SPA, it works fine.
However, if I press F5 to enable debugging, even when debug=false
on the web.config
, my page does not load correctly. When I checked the developer tools, I found this.
If I check my code and my scripts library, it seems OK.
BundleConfig.cs:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
AddDefaultIgnorePatterns(bundles.IgnoreList);
bundles.Add(
new ScriptBundle("~/scripts/modernizr")
.Include("~/scripts/modernizr-{version}.js"));
bundles.Add(
new ScriptBundle("~/scripts/vendor")
.Include("~/scripts/jquery-{version}.min.js")
.Include("~/scripts/bootstrap.min.js")
.Include("~/scripts/knockout-{version}.js")
.Include("~/scripts/toastr.js"));
bundles.Add(
new StyleBundle("~/Content/css")
.Include("~/Content/ie10mobile.css") // Must be first. IE10 mobile viewport fix
.Include("~/Content/bootstrap.min.css")
.Include("~/Content/bootstrap-responsive.min.css")
.Include("~/Content/font-awesome.min.css")
.Include("~/Content/toastr.css")
.Include("~/Content/styles.css")
);
}
And the VS studio structure, the files are there.
If I check my index.cshtml
@using System.Web
@using System.Web.Optimization
<!DOCTYPE html>
<html>
<head>
<title>CCJS</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
@Styles.Render("~/Content/css")
<script language="javascript">
// Must be first. IE10 mobile viewport fix
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
var mq = "@@-ms-viewport{width:auto!important}";
msViewportStyle.appendChild(document.createTextNode(mq));
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
</script>
@Scripts.Render("~/scripts/modernizr")
</head>
<body>
<div id="applicationHost">
@RenderPage("_splash.cshtml")
</div>
@Scripts.Render("~/scripts/vendor")
<script src="~/Scripts/require.js" data-main="App/Main"></script>
</body>
</html>
Upvotes: 2
Views: 162
Reputation: 2768
You can add this line to your BundleConfig.cs
//note: you can map isCompressionEnabled to your webconfig appSettings
BundleTable.EnableOptimizations = isCompressionEnabled;
Upvotes: 1