在一个简单的 ASP.Net MVC4 测试应用程序中,我安装了无点 NuGet 包并按照本教程进行操作。
我的.less
文件被正确解析为 CSS 并且在debug=true
.
<link href="/Public/less/main.less" rel="stylesheet"/>
<link href="/Public/less/home.less" rel="stylesheet"/>
<link href="/Public/less/a.less" rel="stylesheet"/>
<link href="/Public/less/b.less" rel="stylesheet"/>
<link href="/Public/less/c.less" rel="stylesheet"/>
但是,当我设置debug=false
它以使其缩小并合并为单个样式表时,我得到了这个:
<link href="/Public/less?v=" rel="stylesheet"/> // NOT WORKING!
这是我的捆绑配置文件;再次,直接取自教程:
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
// Compile .less files and create a bundle for them.
var lessBundle = new Bundle("~/Public/less").Include(
"~/Public/less/main.less",
"~/Public/less/home.less",
"~/Public/less/a.less",
"~/Public/less/b.less",
"~/Public/less/c.less");
lessBundle.Transforms.Add(new LessTransform());
lessBundle.Transforms.Add(new CssMinify());
bundles.Add(lessBundle);
}
}
在我的布局文件中:
<head>
@Styles.Render("~/Public/less")
</head>
这是我的 LessTransform 类:
public class LessTransform : IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}
}
关于为什么捆绑包无法正常工作的任何想法debug=false
?