LESS CSS - 提取生成的CSS

时间:2021-10-11 09:51:27

I am trying to use LESS CSS to write my CSS. I have imported the style.less and less.js file in that order.

我正在尝试使用LESS CSS来编写我的CSS。我按顺序导入了style.less和less.js文件。

Now i wanna extract the CSS that LESS generates.. is there any way i can do that ? i dont want to use the script to generate it dynamically in production. just for development.

现在我想提取LESS生成的CSS ..有什么方法可以做到吗?我不想使用脚本在生产中动态生成它。只是为了发展。

4 个解决方案

#1


3  

http://incident57.com/less/ if you're fortunate enough to use OS X, and there's a ruby gem too http://rubygems.org/gems/less although this has been superseded by the node.js implementation installed through npm. Check http://lesscss.org/ for more information.

http://incident57.com/less/如果你有幸使用OS X,并且还有一个ruby gem http://rubygems.org/gems/less虽然已经被node.js实现安装所取代通过npm。查看http://lesscss.org/了解更多信息。

There's also http://www.dotlesscss.org/ for windows, but not sure how useful it is.

对于Windows也有http://www.dotlesscss.org/,但不确定它有多有用。

#2


5  

You can extract the CSS using the Firebug extension in Firefox. The compiled CSS appears under the menu choice "inline" in the CSS tab.

您可以使用Firefox中的Firebug扩展来提取CSS。编译的CSS显示在CSS选项卡的菜单选项“inline”下。

#3


1  

And in 2013 we have:

2013年,我们有:

http://less2css.org/

Seems to work just fine for me. Just copy/paste.

似乎对我来说工作得很好。只需复制/粘贴。

Chances are you'll want to minify your CSS after this, so:

您可能希望在此之后缩小CSS,因此:

http://cssminifier.com/

#4


0  

For others who'd stumble here, in modern browser you can see it in the LocalStorage. I use Chrome and it's in the dev toolbar under Resources. In my case we also want to save the css file automatically (we have a tool that generates a template), we can do it easily with javascript.

对于那些在这里绊倒的人,在现代浏览器中,您可以在LocalStorage中看到它。我使用Chrome,它位于资源下的开发工具栏中。在我的情况下,我们还想自动保存css文件(我们有一个生成模板的工具),我们可以使用javascript轻松完成。

This returns the generated CSS, just replace it with the right path, as you see it under the Resources tab: localStorage.getItem('http://domain.com/css/main.less');

这将返回生成的CSS,只需将其替换为正确的路径,就像在“资源”选项卡下看到的那样:localStorage.getItem('http://domain.com/css/main.less');

Then we send that through Ajax to save it in a css file. When switching to production we remove the less and replace it by the generated css file.

然后我们通过Ajax发送它以将其保存在css文件中。切换到生产时,我们删除less并用生成的css文件替换它。

#1


3  

http://incident57.com/less/ if you're fortunate enough to use OS X, and there's a ruby gem too http://rubygems.org/gems/less although this has been superseded by the node.js implementation installed through npm. Check http://lesscss.org/ for more information.

http://incident57.com/less/如果你有幸使用OS X,并且还有一个ruby gem http://rubygems.org/gems/less虽然已经被node.js实现安装所取代通过npm。查看http://lesscss.org/了解更多信息。

There's also http://www.dotlesscss.org/ for windows, but not sure how useful it is.

对于Windows也有http://www.dotlesscss.org/,但不确定它有多有用。

#2


5  

You can extract the CSS using the Firebug extension in Firefox. The compiled CSS appears under the menu choice "inline" in the CSS tab.

您可以使用Firefox中的Firebug扩展来提取CSS。编译的CSS显示在CSS选项卡的菜单选项“inline”下。

#3


1  

And in 2013 we have:

2013年,我们有:

http://less2css.org/

Seems to work just fine for me. Just copy/paste.

似乎对我来说工作得很好。只需复制/粘贴。

Chances are you'll want to minify your CSS after this, so:

您可能希望在此之后缩小CSS,因此:

http://cssminifier.com/

#4


0  

For others who'd stumble here, in modern browser you can see it in the LocalStorage. I use Chrome and it's in the dev toolbar under Resources. In my case we also want to save the css file automatically (we have a tool that generates a template), we can do it easily with javascript.

对于那些在这里绊倒的人,在现代浏览器中,您可以在LocalStorage中看到它。我使用Chrome,它位于资源下的开发工具栏中。在我的情况下,我们还想自动保存css文件(我们有一个生成模板的工具),我们可以使用javascript轻松完成。

This returns the generated CSS, just replace it with the right path, as you see it under the Resources tab: localStorage.getItem('http://domain.com/css/main.less');

这将返回生成的CSS,只需将其替换为正确的路径,就像在“资源”选项卡下看到的那样:localStorage.getItem('http://domain.com/css/main.less');

Then we send that through Ajax to save it in a css file. When switching to production we remove the less and replace it by the generated css file.

然后我们通过Ajax发送它以将其保存在css文件中。切换到生产时,我们删除less并用生成的css文件替换它。