How to add specific files to assetic?

前端 未结 4 892
滥情空心
滥情空心 2021-02-14 04:53

I have my custom resources directory for my bundle where there are some files:

/longpathtoSymfony/src/MyOwn/Bundle/MyOwnBundle/Resources/public
|-- bootstrap
|           


        
4条回答
  •  终归单人心
    2021-02-14 05:14

    Part of answer was taken from here

    How to set assets path for js, css and fonts

    {% stylesheets
        '@bootstrap_css'#this is some custom or bundled files which you want to include
        'bundles/mybundle/css/custom.css'
        filter="cssrewrite"
        output='some/path/to.css'
    %}
    

    this part will build all css which are presented in one file and put it to path which also presented in code sample. Now to.css will be placed in /web/some/path/to.css

    the same is for JS:

    {% javascripts
        '@jquery' #this is some custom or bundled files which you want to include
        '@bootstrap_js'
        'bundles/fosjsrouting/js/router.js'
        output='js/compiled/app.js'
    %}
    

    Now you'll have all js which build in 1 file with path /web/js/compiled/app.js

    FY : In latest versions of symfony Assetic bundle doesn't exist from box - it should be installed additionally via composer by composer require symfony/assetic-bundle

提交回复
热议问题