0

I have a Less file which includes a CSS file, then a set of Less files. With SquishIt I want to combine and minify these, but it ignores the CSS file unless I rename it to .css.less. I believe ProcessIncludes() is intended for this purpose but makes no difference.

Does anyone know why ProcessIncludes() doesn't do anything on a CSS file linked in a Less file?

(This is a follow up to: this question about Squishit.Less not working at all, it now works for the Less files.)

Community
  • 1
  • 1
Ian Grainger
  • 5,148
  • 3
  • 46
  • 72

2 Answers2

1

There is a configuration option for dotLess called "InlineCssFiles" that I believe does what you need. You can use your own configuration by overriding the static property "EngineBuilder" (its a Func) on less preprocessor. So in App_Start you could do something like this:

LessPreprocessor.EngineBuilder = () => new EngineFactory
            {
                Configuration = new DotlessConfiguration
                    {
                        InlineCssFiles = true,
                    }
            }.GetEngine();
AlexCuse
  • 18,008
  • 5
  • 42
  • 51
  • I have an issue on my test server that means I can't test this at the moment - but that sounds like the option I needed instead of ProcessIncludes. I can't find any decent docs for SquishIt.Less - I guess I needed to open the source! :\ – Ian Grainger Nov 29 '13 at 09:49
  • Yeah that's always a problem. I think I'm going to spend a little time adding /// comments to the important public methods and see what is out there to generate docs from that. I don't really use .less but I read a bit yesterday and I think that the option above will help you. – AlexCuse Dec 01 '13 at 01:08
  • Not sure when I can go back to test this. Have an answer. – Ian Grainger Dec 02 '13 at 11:54
0

According to LESS documentation:

You can import both CSS and LESS files. Only LESS files import statements are processed, CSS file import statements are kept as they are.

You can force LESS to process a CSS file by:

@import (less) "file.css";

Note however that all this applies to the official LESS implementation and may not work in SquishIt. SquishIt seems to use the dotless compiler which is pretty much outdated.

seven-phases-max
  • 11,765
  • 1
  • 45
  • 57