简体   繁体   English

SquishIt.Less ProcessIncludes()对CSS文件不起作用

[英]SquishIt.Less ProcessIncludes() not working for CSS file

I have a Less file which includes a CSS file, then a set of Less files. 我有一个Less文件,其中包括一个CSS文件,然后是一组Less文件。 With SquishIt I want to combine and minify these, but it ignores the CSS file unless I rename it to .css.less. 我想使用SquishIt合并并缩小它们,但是除非我将其重命名为.css.less,否则它将忽略CSS文件。 I believe ProcessIncludes() is intended for this purpose but makes no difference. 我相信ProcessIncludes()用于此目的,但没有区别。

Does anyone know why ProcessIncludes() doesn't do anything on a CSS file linked in a Less file? 有谁知道为什么ProcessIncludes()对在Less文件中链接的CSS文件不执行任何操作?

(This is a follow up to: this question about Squishit.Less not working at all, it now works for the Less files.) (这是以下问题的跟进:关于Squishit.Less根本不起作用的问题 ,现在适用于Less文件。)

There is a configuration option for dotLess called "InlineCssFiles" that I believe does what you need. 我相信dotLess有一个名为“ InlineCssFiles”的配置选项,可以满足您的需求。 You can use your own configuration by overriding the static property "EngineBuilder" (its a Func) on less preprocessor. 您可以通过在较少的预处理器上覆盖静态属性“ EngineBuilder”(其为Func)来使用自己的配置。 So in App_Start you could do something like this: 因此,在App_Start中,您可以执行以下操作:

LessPreprocessor.EngineBuilder = () => new EngineFactory
            {
                Configuration = new DotlessConfiguration
                    {
                        InlineCssFiles = true,
                    }
            }.GetEngine();

According to LESS documentation: 根据LESS文档:

You can import both CSS and LESS files. 您可以导入CSS和LESS文件。 Only LESS files import statements are processed, CSS file import statements are kept as they are. 仅处理LESS文件导入语句,而CSS文件导入语句保持原样。

You can force LESS to process a CSS file by: 您可以通过以下方式强制LESS处理CSS文件:

@import (less) "file.css";

Note however that all this applies to the official LESS implementation and may not work in SquishIt. 但是请注意,所有这些都适用于官方的LESS实施,并且可能在SquishIt中不起作用。 SquishIt seems to use the dotless compiler which is pretty much outdated. Squish它似乎使用了几乎已经过时的无点编译器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM