简体   繁体   中英

How to minify CSS and JS files using BundleConfig

I have been trying to bundle and minify my local CSS and JS files using ASP.NET MVC 4.6 Bundle Config. I have tried the code below for CSS bundling:

    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;
    }

This creates a bundle CSS file. However, the bundle file is not minified. I was wondering if this is possible.

Thank you,

Run your application in release mode and check what happened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM