问题
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.)
回答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();
回答2:
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.
来源:https://stackoverflow.com/questions/20263389/squishit-less-processincludes-not-working-for-css-file