如果没有 Node.js,您将如何在 symfony2+Assetic 项目上使用 LESS

发布于 2025-01-04 17:31:31 字数 430 浏览 9 评论 0原文

别误会我的意思。我知道我们有 lessc 甚至其他 php 编译器(我说的是 lessphp) 和其他。

但!你知道,我真的很喜欢less.js 工作方式

我的意思是...

  • 指向您的 less 文件
  • 指向 javascript
  • 工作

当您完成时

  • 从浏览器获取 localStorage 版本
  • 将其放入 CSS 文件中。

你有没有想过用一种方法来做类似的事情?

Don't get me wrong. I know we had lessc and even other compilers in php (I'm talking about lessphp) and others.

But! You know, I really like less.js way to work.

What I mean...

  • point to your less file
  • Point to the javascript
  • work

When you are done

  • Get the localStorage version from the browser
  • Put it into a CSS file.

Have you ever thought of a way to do something similar?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念三年u 2025-01-11 17:31:31

不完全确定我理解这个问题。我将 sass 与 Symfony-2 一起使用。工作正常。有时我使用 --watch 选项进行自动更新。有时我会使用 Assetic scss 过滤器。从来没有少用过,但有一个过滤器。

我总是只签入最终的 css 文件,这样我就不需要在部署期间生成一个文件。

Not entirely sure i understand the question. I use sass with Symfony-2. Works fine. Sometimes I use the --watch option for automatic updates. Sometimes I use the Assetic scss filter. Never used less but there is a filter for it.

I always just checkin the final css file so I don't need to fool with generating one during deployment.

待天淡蓝洁白时 2025-01-11 17:31:31

有一篇关于将 lessphp 与 assetic 一起使用的帖子:(因此不需要 Nodejs)

用于 Symfony2.1:https://gist。 github.com/3049271
对于 Symfony2.0: https://gist.github.com/1844433

seps:

添加以下行将代码添加到composer.json文件中:

"leafo/lessphp": "*"

运行composer install
最好的方法是将文件: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php 添加到 config.yml 文件中:

#...
assetic:
    #...
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"

然后在模板中您可以使用如下所示的 less :

{% stylesheets '@AppBundle/Resources/public/bootstrap/less/bootstrap.less*' %}
        <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

There is a post about using lessphp with assetic: (so no nodejs needed)

for Symfony2.1: https://gist.github.com/3049271
for Symfony2.0: https://gist.github.com/1844433

The seps:

Add the following lines of code to the composer.json file:

"leafo/lessphp": "*"

Run composer install
The best approach is to add file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php to config.yml file:

#...
assetic:
    #...
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"

and then in your template you can use the less like this:

{% stylesheets '@AppBundle/Resources/public/bootstrap/less/bootstrap.less*' %}
        <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文