Symfony资产样式表捆绑公用文件夹的路径?

时间:2022-03-14 00:29:37

I read this and this

我读了这个和这个

I want to simply include stylesheets with assetic in my template. I want to keep all css files in the bundle public dir. Not in any app/ dir from another dir tree.

我想在我的模板中简单地包含带有资产的样式表。我想将所有css文件保存在bundle public目录中。不在另一个目录树的app / dir中。

My webroot to the bundle CSS tree: [webroot]/src/Myvendor/MyBundle/Resources/public/css/

我的webroot到bundle CSS树:[webroot] / src / Myvendor / MyBundle / Resources / public / css /

So i took this example

所以我拿了这个例子

{# base.html.twig #}
{% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

Naturally this did not work with the example path on me, so i tried to insert my path. I dont want to make use of @MyvendorMyBundle/Resources/public/js/* due to the fact of the cssrewrite problems. But making use of this path, the css is going to be taken.

当然这对我的示例路径不起作用,所以我试图插入我的路径。由于cssrewrite问题,我不想使用@ MyvendorMyBundle / Resources / public / js / *。但是利用这条路径,css将会被采用。

So i tried every relative constellation of my css path. And no one worked..

所以我尝试了我的css路径的每个相对星座。没有人工作..

  • src/Myvendor/MyBundle/Resources/public/css/*
  • src/MyvendorMyBundle/Resources/public/css/*
  • Myvendor/MyBundle/Resources/public/css/*
  • MyvendorMyBundle/Resources/public/css/*
  • MyBundle/Resources/public/css/*
  • Resources/public/css/*
  • public/css/*
  • css/*
  • bundles/app/css/*
  • bundles/Myvendor/MyBundle/Resources/public/css/*
  • bundles/MyvendorMyBundle/Resources/public/css/*
  • bundles/MyBundle/Resources/public/css/*
  • bundles/Resources/public/css/*
  • bundles/public/css/*
  • ../public/css/*

I really googled and found only examples that did not work for me, and they seems that they were all in the /app/Resources/foo... but i dont want this, it must stay in the bundle.

我真的用谷歌搜索,发现只有不适合我的例子,他们似乎都在/ app / Resources / foo ...但我不想要这个,它必须留在捆绑中。

What im doing wrong? Thanks in advice.

我做错了什么?谢谢你的建议。

1 个解决方案

#1


2  

Well, if you don't move your stylesheet anywhere it is in src/Easylearn/QuerybuildBundle/Resources/public/css/. However, when using relative paths, they are relative to the web/ directory. So do ../src/Easylearn/QuerybuildBundle/Resources/public/css/.

好吧,如果你没有将样式表移动到src / Easylearn / QuerybuildBundle / Resources / public / css /中的任何位置。但是,使用相对路径时,它们相对于web /目录。所以../src/Easylearn/QuerybuildBundle/Resources/public/css/。

I'm not sure actually why you don't set-up a symlink from all public/ directories in bundles to web/bundles (by running app/console assets:install --symlink).

我不确定为什么你没有设置从捆绑包中的所有公共/目录到web / bundles的符号链接(通过运行app / console assets:install --symlink)。

#1


2  

Well, if you don't move your stylesheet anywhere it is in src/Easylearn/QuerybuildBundle/Resources/public/css/. However, when using relative paths, they are relative to the web/ directory. So do ../src/Easylearn/QuerybuildBundle/Resources/public/css/.

好吧,如果你没有将样式表移动到src / Easylearn / QuerybuildBundle / Resources / public / css /中的任何位置。但是,使用相对路径时,它们相对于web /目录。所以../src/Easylearn/QuerybuildBundle/Resources/public/css/。

I'm not sure actually why you don't set-up a symlink from all public/ directories in bundles to web/bundles (by running app/console assets:install --symlink).

我不确定为什么你没有设置从捆绑包中的所有公共/目录到web / bundles的符号链接(通过运行app / console assets:install --symlink)。