jQuery不在ASP.NET MVC中缩小



我正在使用asp.net mvc。

由于某些原因,我的JS文件没有缩小。我的CSS缩小了。

我的CSS将减为:<link href="/ffee/content/css?v=vaNo49ei5GzRQAYnj-AD-AbQI3GKNs2OZ8q6-oJEEvk1" rel="stylesheet">,但我所有的JS文件均在源中分别列出。

我正在以发行模式编译和发布。

任何人都可以建议我如何解决这个问题?

谢谢,

马克

bootstrapbundleconfig.cs

using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
namespace BootstrapSupport
{
public class BootstrapBundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/js").Include(
            "~/Scripts/jquery-{version}.js",
            "~/Scripts/jquery-migrate-{version}.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/jquery.validate.js",
            "~/scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js",
            "~/Scripts/knockout-2.2.0.js",
            "~/Scripts/bootstrap-combobox.js",
             "~/Scripts/select2.js"
            ));
        bundles.Add(new ScriptBundle("~/mt").Include(
           "~/Scripts/bootstrap-datepicker.js",
                            "~/Scripts/mtDateEdit.js",
                            "~/Scripts/jquery-te-1.4.0.js"
                            //"~/Scripts/tinymce/tinymce.js"
                            ));
        bundles.Add(new StyleBundle("~/content/css").Include(
            "~/Content/bootstrap.css",
            "~/Content/body.css",
            "~/Content/bootstrap-responsive.css",
            "~/Content/bootstrap-mvc-validation.css",
            "~/Content/bootstrap-combobox.css",
             "~/Content/select2.css",
            "~/Content/datepicker.css",
            "~/Content/jquery-te-1.4.0.css"
            ));
    }
}
}

global.asax.cs

   public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AuthConfig.RegisterAuth();
        BootstrapSupport.BootstrapBundleConfig.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);
        BootstrapMvcSample.ExampleLayoutsRouteConfig.RegisterRoutes(RouteTable.Routes);
        RegisterViewMapper();
    }

_bootstrap.layout.basic.cshtml-在文件的底部:

 <div class="container">
     @Scripts.Render("~/js")
     @Scripts.Render("~/mt")
     @RenderSection("Scripts", required: false)
     @Html.Partial("_alerts")
     @Html.Partial("_validationSummary")
     @RenderBody()   
 </div>

尝试用BundleTable.EnableOptimizations = true;

强迫它

如果您说的是缩小/捆绑错误,请从捆绑包中删除*.js文件,直到找到违规的文件。找到它后,尝试在此文件的顶部和末尾添加lineFeed。

您可以将其强制为仅发布模式

 #if RELEASE            
        BundleTable.EnableOptimizations = true;            
 #endif

最新更新