如何缩小文件夹 ASP.net 中的 css

How to minify css in a folder ASP.net

我的文件夹中有 CSS 个文件,我打算使用磁带将它们缩小 到目前为止

我创建了一个class

    public class CSSBundleHelper : IConfiguration<BundleCollection>
    {
        public void Configure(BundleCollection bundles)  
        {
            var BundlePath =      ConfigurationManager.AppSettings["CSSBundleFolder"];
        var path = ConfigurationManager.AppSettings["CMSSitesPath"];
        bundles.AddPerSubDirectory<StylesheetBundle>(path);
        }
    }
}

由于文件在一个文件夹中,我不知道如何调用此函数并进行捆绑。如果有人能指导我,我会很高兴

如果您的 css 文件在一个文件夹中,只需将应用程序相对路径传递给 bundles.Add(path-to-css-folder)

然后使用这个包,即在 Razor 中:添加 @Bundles.RenderStyleSheets()