LESS CSS - 提取生成的 CSS
我正在尝试使用 LESS CSS 来编写我的 CSS。我已按顺序导入了 style.less 和 less.js 文件。
现在我想提取 LESS 生成的 CSS..有什么办法可以做到这一点吗?我不想使用脚本在生产中动态生成它。只为发展。
I am trying to use LESS CSS to write my CSS. I have imported the style.less and less.js file in that order.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 Firefox 中的 Firebug 扩展来提取 CSS。编译后的 CSS 出现在 CSS 选项卡中的菜单选项“inline”下。
You can extract the CSS using the Firebug extension in Firefox. The compiled CSS appears under the menu choice "inline" in the CSS tab.
http://incident57.com/less/ 如果您有幸使用 OS X,并且有一个ruby gem 也是http://rubygems.org/gems/less,尽管它已被节点取代。 js 实现通过安装npm。查看 http://lesscss.org/ 了解更多信息。
还有用于 Windows 的 http://www.dotlesscss.org/,但不确定它有多有用。
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.
There's also http://www.dotlesscss.org/ for windows, but not sure how useful it is.
在 2013 年,我们有:
http://less2css.org/
似乎对我来说效果很好。只需复制/粘贴。
在此之后您可能会想要缩小 CSS,因此:
http://cssminifier.com/
And in 2013 we have:
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:
http://cssminifier.com/
对于那些在这里绊倒的人,在现代浏览器中,您可以在 LocalStorage 中看到它。我使用 Chrome,它位于资源下的开发工具栏中。
就我而言,我们还想自动保存 css 文件(我们有一个生成模板的工具),我们可以使用 javascript 轻松完成。
这将返回生成的 CSS,只需将其替换为正确的路径,如您在“资源”选项卡下看到的那样:
<代码>
localStorage.getItem('http://domain.com/css/main.less');
然后我们通过 Ajax 发送它,将其保存在 css 文件中。当切换到生产环境时,我们删除 less 并用生成的 css 文件替换它。
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.
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');
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.