asp mvc IIS7 less/sass empty file



我试着在我的新项目中使用更少。我已经安装了dotLess和System.Web.Optimization.Less包(正如另一篇"Add LESS to your ASP"中所描述的那样)。. NET MVC项目"Post")和本地一切工作正常。但是当我发布项目IIS7服务器响应空css文件/Content/Main/site?v=

这是我的web.config

...
<configSections>
  <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
</configSections>
<system.web>
  <httpHandlers>
  <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
</system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    <add name="dotless" path="*.LESS" verb="*" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition=""/>
  </handlers>
</system.webServer>
<dotless minifyCss="false" cache="true" web="false" />

和BundleConfig.cs

bundles.Add(new LessBundle("~/Content/Main/site").Include("~/Content/Main/Site.less"));

当我添加css扩展到我的网站。less文件(Site.less.css)服务器响应内容(/Content/Main/site?v=K-FFpFNtIXPUlQamnX3qHX_A5r7TM2xbAgcuEmpm3O41),但它仍然是纯less的所有变量等

Bundle Transformer: Sass and SCSS相同

我错过了什么?

当你得到

/内容/主/网站吗?v = K-FFpFNtIXPUlQamnX3qHX_A5r7TM2xbAgcuEmpm3O41

则表示绑定工作正常。因此,可能是Site.less中的某些东西导致了这个问题。需要注意的一点是相对url。例如,如果你的css中有一张图片

.bacon {
    background-image: url(bacon.png);
}

bundle将从bundle的名称中查找~/Content/Main。(/site很好,可以是任何东西,它只是包的名称)

要尝试的第一件事是拿出任何导入,图像等,看看它是否正确捆绑。你可以通过在bundle配置中启用优化,在本地开发构建中实现这一点。

BundleTable.EnableOptimizations = true

解决这个问题的另一种方法是消除对System.Web.Optimization.LessdotLess的依赖,并使用免费的Visual Studio扩展https://github.com/madskristensen/WebCompiler预编译less to css(有或没有缩小)

最新更新