如何使用 BundleConfig 缩小 CSS 和 JS 文件

时间:2021-04-13 18:24:48

标签: c# asp.net-mvc bundle minify

我一直在尝试使用 ASP.NET MVC 4.6 捆绑配置来捆绑和缩小我的本地 CSS 和 JS 文件。 我已尝试使用以下代码进行 CSS 捆绑:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.IgnoreList.Clear();

        bundles.Add(new StyleBundle("~/Content/css/bundleStylesheets").Include(
                                                    "~/Content/css/custom-select.css",
                                                    "~/Content/css/main.css",
                                                    "~/Content/css/homepage.css",
                                                    "~/Content/css/asset-preview.css",
                                                    "~/Content/css/casestudy.css",
                                                    "~/Content/css/admin.css",
                                                    "~/Content/css/judgework.css",
                                                    "~/Content/css/submissions.css",
                                                    "~/Content/css/gallery.css"));

        BundleTable.EnableOptimizations = true;
    }

这会创建一个包 CSS 文件。但是,捆绑文件不会缩小。我想知道这是否可能。

谢谢,

1 个答案:

答案 0 :(得分:0)

在发布模式下运行您的应用程序并检查发生了什么。