Install vendor resources in web directory

后端 未结 1 1196
旧巷少年郎
旧巷少年郎 2021-01-22 06:46

I have in my bundle in Resources a directory called vendor which contains JavaScript libraries, etc. Some of those vendors contain images.

I ca

1条回答
  •  一生所求
    2021-01-22 07:19

    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' %}
         
     {% endstylesheets %}
    

    or

     {% image '@my_image' %}
         Example
     {% endimage %}
    

    0 讨论(0)
提交回复
热议问题