Install vendor resources in web directory

五迷三道 提交于 2019-12-02 00:54:15

Assetic's asset collections like

assetic:
    assets:
        collection_name:
            inputs:
                 - ...
            output: 
                 - desired_filename # relative to assetic.output_path
            filters:
                 - ?lessphp          # scss, optipng, jpegoptim ... whatever
                                     # the ? (question mark) prevents the 
                                     # filter to be applied in dev mode 

can also contain images. but you have to specify them one by one

assetic:
    assets:

        [...] 

        my_image:
            inputs:
                 - /path/to/image/image.png
            output: 
                 - images/smushed_image.png  
            filters:
                 - optipng    

        my__second_image:
            inputs:
                 - /path/to/image/image2.jpg
            output: 
                 - images/smushed_image2.jpg
            filters:
                 - jpegoptim       

Then use the assetic:dump command to have them written ( and compiled / smushed ) to your web folder. The --no-debug option prevents assetic from creating debug files for every single file in every package. Use for production systems or if you have another way of debugging ( i.e. the awesome Source Maps )

app/console assetic:dump --no-debug

Use the packages like this:

 {% stylesheets '@collection_name' %}
     <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
 {% endstylesheets %}

or

 {% image '@my_image' %}
     <img src="{{ asset_url }}" alt="Example"/>
 {% endimage %}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!