Symfony2 assets versioning by file

前端 未结 4 875
长情又很酷
长情又很酷 2020-12-31 14:59

Question

Is it possible on Symfony2 use assets_version by file?

Background

We are using assets_version and assets_version_format to

4条回答
  •  长情又很酷
    2020-12-31 15:28

    After many days searching I found the packages option on AsseticBundle

    http://symfony.com/doc/2.0/reference/configuration/framework.html#full-default-configuration

    Using that config option I could do something like this:

    {% javascripts file package='packageName' %}
    

    or

    {{asset(file,packageName)}}
    

    Sample:

    config.yml

    framework:
    
        templating:
            engines: ['twig']
            assets_version: %assets_version%
            assets_version_format:  "stv%%2$s/%%1$s"
            packages:
                 css:
                    version: 6.1
                    version_format: "stv%%2$s/%%1$s"
                 jsApp:
                    version: 4.2
                    version_format: "stv%%2$s/%%1$s"
    

    sometemplate.html.twig

    
    
    {% javascripts 'bundles/webapp/js/app.js'
                   'bundles/webapp/js/utils.js'
                    filter='?closure'
                    package='jsApp'
     %}
        
     {% endjavascripts %}
    

    The output of this is:

    
    
    
    

    For me that was the simplest way to manage assets version by file.

提交回复
热议问题