11

我所有的 javascript 和 css 结合在一起。但是当我在寻找它们时,它们并没有缩小。我不知道为什么。

我的捆绑包如下所示:

         bundles.Add(new Bundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery-ui.js",
            "~/Scripts/jquery.validate.js",
            "~/Scripts/grid.locale-tr.js",
            "~/Scripts/jquery.jqGrid.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/messages_tr.js",
             "~/Scripts/jquery.form.js"
           )
       );
        bundles.Add(new Bundle("~/bundles/mainjs").Include(
            "~/Scripts/jquery-1.10.2.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/superfish.js",
            "~/Scripts/jquery.flexslider.js",
            "~/Scripts/jquery.kwicks-1.5.1.js",
            "~/Scripts/jquery.easing.1.3.js",
            "~/Scripts/jquery.cookie.js",
            "~/Scripts/touchTouch.jquery.js"
           )
       );

        bundles.Add(new Bundle("~/bundles/allcss").Include(
           "~/Content/Css/bootstrap*",
           "~/Content/Css/opa-icons.css",
           "~/Content/Css/charisma-app.css",
           "~/Content/Css/ui.jqgrid.css",
           "~/Content/Css/jquery-ui.css"
           )
       );

        bundles.Add(new Bundle("~/bundles/maincss").Include(
           "~/Content/Css/bootstrap.css",
           "~/Content/Css/responsive.css",
           "~/Content/Css/style.css",
           "~/Content/Css/touchTouch.css",
           "~/Content/Css/kwicks-slider.css"
           )
       );

我的全局 asax 如下所示:

        protected void Application_Start()
    {
#if DEBUG
        BundleTable.EnableOptimizations = false;
#else
                    BundleTable.EnableOptimizations = true;
#endif
        AreaRegistration.RegisterAllAreas();
        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        GlobalConfiguration.Configuration.MessageHandlers.Add(new CorsHandler());
    }

和:

 @System.Web.Optimization.Scripts.Render("~/bundles/mainjs")
 @System.Web.Optimization.Styles.Render("~/bundles/maincss")
4

2 回答 2

20

它们没有被缩小,因为您使用的是 Bundle 而不是 ScriptBundle。Bundle仅将它们捆绑在一起(嘿,一句话:))ScriptBundle捆绑并缩小。

于 2014-02-05T16:29:33.150 回答
7

它们没有缩小,因为您可能处于DEBUG模式。

尝试设置这个

BundleTable.EnableOptimizations = true;

看看会发生什么。

于 2013-10-09T11:09:31.647 回答