Error finding LESS file when compiling

Jul 6, 2012 at 1:28 PM

I configured combres to use Twitter Bootstrap less files and its working when I'm on debug mode but when the option is set to false it throws this error:

 

System.IO.FileNotFoundException: You are importing a file ending in .less that cannot be found.

 

I'm using MVC4, VS2010, Combres 2.2.2.6 installed from nuget

 

Thanks for any help

 

Coordinator
Jul 9, 2012 at 5:45 PM

Hi, thanks for reporting. Can you post the sample project containing just the error for easy reproducing & troubleshooting?

Jul 9, 2012 at 6:49 PM

Sure, download the project from here

https://dl.dropbox.com/u/7398/Bootstrap.zip

On combres.xml change defaultDebugEnabled from true to false and it will fail when loading that resource set.

Thanks

Coordinator
Jul 10, 2012 at 9:53 PM

Hi, thanks for posting the code.  There's a closely related issue reported here.  For Combres to work in these scenarios, you have to remove all the @import in the less file and reference those files directly in combres.xml; then use DotLessCssCombineFilter to process those less files. Your combres.xml should look something like this:

<?xml version="1.0" encoding="utf-8"?>

<!--
  This file contains basic settings needed for most web apps.
  For full Combres settings (with explanation), refer to the sample definition file: combres_full_with_annotation.xml
  Also, refer to Combres' documentation: http://combres.codeplex.com/documentation	
-->
<combres xmlns='urn:combres'>
  <filters>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
    <filter type="Combres.Filters.HandleCssVariablesFilter, Combres" />
    <filter type="Combres.Filters.DotLessCssFilter, Combres" />
    <filter type="Combres.Filters.DotLessCssCombineFilter, Combres" 
            acceptedResourceSets="bootstrap-theme-css"/>
  </filters>
  <cssMinifiers>
    <minifier name="yui" type="Combres.Minifiers.YuiCssMinifier, Combres">
      <param name="CssCompressionType" type="string" value="StockYuiCompressor" />
      <param name="RemoveComments" type="bool" value="true" />
      <param name="ColumnWidth" type="int" value="-1" />
    </minifier>
  </cssMinifiers>
  <jsMinifiers>
    <minifier name="yui" type="Combres.Minifiers.YuiJSMinifier, Combres">
      <param name="IsVerboseLogging" type="bool" value="false" />
      <param name="IsObfuscateJavascript" type="bool" value="true" />
      <param name="PreserveAllSemicolons" type="bool" value="false" />
      <param name="DisableOptimizations" type="bool" value="false" />
      <param name="LineBreakPosition" type="int" value="-1" />
    </minifier>
  </jsMinifiers>
  <resourceSets url="~/combres" 
                defaultJSMinifierRef="yui" 
                defaultCssMinifierRef="yui" 
                defaultDuration="7"
                defaultVersion="auto" 
                defaultDebugEnabled="false" 
                defaultIgnorePipelineWhenDebug="true" 
                defaultCompressionEnabled="true"
                localChangeMonitorInterval="1" 
                remoteChangeMonitorInterval="60">
    <resourceSet name="bootstrap-theme-css" type="css">
      <resource path="~/Content/themes/bootstrap/less/reset.less" />
      <resource path="~/Content/themes/bootstrap/less/variables.less" />
      <resource path="~/Content/themes/bootstrap/less/mixins.less" />>
      <!-- more resources here -->
    </resourceSet>
  </resourceSets>
</combres>

Jul 11, 2012 at 2:47 PM

Hi buunguyen, thanks for the help. I removed the imports, added al less files and added the filter and it didn’t work, but it didn’t throw any errors this time. If I’m in debug mode the server responds with a blank file for each less file. Where you able to make it work with the project I sent?

Thanks

Jul 31, 2012 at 4:10 PM

Here is what I believe to be the correct implementation of the dotless filter that handles imports correctly. Please let me know if you would like me to fork the fix for you guys.

Coordinator
Aug 11, 2012 at 10:39 PM

@malave: can you send the sample project again?

@theonlylawislove: nice, does it work with parent folder, e.g. ../another.less?

Aug 14, 2012 at 3:39 PM

@buunguyen the link still, I haven’t tried @theonlylawislove yet but most likely I will try it sometime today

 

https://dl.dropbox.com/u/7398/Bootstrap.zip

Aug 16, 2012 at 10:31 PM

#buunguyen: Yes, the following work all work.

  • @import "variables.less"
  • @import "~/variables.less"
  • @import "../../variables.less"
  • @import "folder/variables.less"
Coordinator
Aug 17, 2012 at 2:46 AM

@theonlylawislove: looks good. Couple of issues:

  • The previous implementation explicitly prevents DotLess to minify and cache to avoid double-minification and -caching; can this do the same?
  • Can you make it work with ICombinedContentFilter as well?
Aug 17, 2012 at 12:47 PM

@buunguyen: I wasn't aware of that when looking into the out-of-the-box implementation. I can check though. It can work with the combined filter, but since the imports work, I personally wouldn't recommend using it. It only minifies .less files, and it it is combined, it will use the entire contents of all the css files in the resource set. Is this a required feature? I think people only used the combined approach because imports didn't work.

Coordinator
Aug 18, 2012 at 7:15 PM

@theonlylawislove: that makes sense; I guess it just gives people flexibility, they can either do all imports within .less files or add individual files in the config and have DotLess runs on the combined string of all files. That should yield similar effect as long as the order is kept right.

The latter has one benefit since now Combres knows about the files being used to generate a response, its change tracking mechanism can monitor changes to the file to generate a new content hash (which cause the url to change => effectively force an auto refresh from browser).  Current change tracking doesn't coordinate with filter/minifier, so Combres wouldn't know about internal imported resources via @import.  Not every one needs this feature (they use manual versioning, or are just happy with the cache settings...) but I, for one, am using auto versioning a lot.

In addition, I don't want to break people's existing code :).

In sort, I still think it's nice to have this combined filter implemented. So if you can help check this out, it's much appreciated.