SquishIt.Less ProcessIncludes() not working for CSS file

限于喜欢 提交于 2019-12-13 05:35:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!