CodeGo.net>如何使用束缚变压器来缩小CSS或JS
作者:互联网
我想使用捆绑变压器捆绑和缩小我的CSS集合
但是,但是我尝试了它不起作用
这是我的代码,请给我一些建议,谢谢.
var nullBuilder = new NullBuilder();
var cssTransformer = new StyleTransformer(new CleanCssMinifier());
var nullOrderer = new NullOrderer();
BundleResolver.Current = new CustomBundleResolver();
var commonStylesBundle = new Bundle("~/bundles/css/site");
commonStylesBundle.IncludeDirectory("~/Content/sass", "*.css");
commonStylesBundle.Builder = nullBuilder;
commonStylesBundle.Transforms.Add(cssTransformer);
commonStylesBundle.Orderer = nullOrderer;
bundles.Add(commonStylesBundle);
它总是像这样输出html:
<link href="/Content/sass/card.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
<link href="/Content/sass/header.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
<link href="/Content/sass/login.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
解决方法:
您需要在配置中将调试模式设置为false.或者在代码中执行以下操作-
BundleTable.EnableOptimizations = true;
标签:minify,asp-net,c 来源: https://codeday.me/bug/20191120/2042955.html