【发布时间】:2012-03-24 11:53:23
【问题描述】:
我正在尝试使用 MVC4 捆绑来对我的一些较少文件进行分组,但看起来我使用的导入路径已关闭。我的目录结构是:
static/
less/
mixins.less
admin/
user.less
在 user.less 中,我尝试使用以下方式导入 mixins.less:
@import "../mixins.less";
以前在使用 chirpy 和 dotless 时这对我有用,但现在我注意到 ELMAH 对我很生气,说:
System.IO.FileNotFoundException:
You are importing a file ending in .less that cannot be found.
File name: '../mixins.less'
我应该在 MVC4 中使用不同的 @import 吗?
一些附加信息
这是我用来尝试这个的 less 类和 global.asax.cs 代码:
LessMinify.cs
...
public class LessMinify : CssMinify
{
public LessMinify() {}
public override void Process(BundleContext context, BundleResponse response)
{
response.Content = Less.Parse(response.Content);
base.Process(context, response);
}
}
...
Global.asax.cs
...
DynamicFolderBundle lessFB =
new DynamicFolderBundle("less", new LessMinify(), "*.less");
BundleTable.Bundles.Add(lessFB);
Bundle AdminLess = new Bundle("~/AdminLessBundle", new LessMinify());
...
AdminLess.AddFile("~/static/less/admin/user.less");
BundleTable.Bundles.Add(AdminLess);
...
【问题讨论】:
-
与您的问题无关,但您能分享一下您用于 Less Parsing 的内容吗?
-
@ShaneCourtrille 查看 nuget.org/packages?q=dotless 我相信我使用的是 dotless 1.3
标签: import asp.net-mvc-4 bundle less asp.net-optimization