Reputation: 1948
I use Symfony2 and the assetic Bundle. (probleme when using the * sign to ask assetic to take all files)
Form what I have read here and there assetic allow to use multiple javascript file.
This work just fine when when I write all the file right before the <'/html> tag:
{% javascripts
'@MySiteBlogBundle/Resources/public/js/test1.js'
'@MySiteBlogBundle/Resources/public/js/test2.js'
'@MySiteBlogBundle/Resources/public/js/test3.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
but the same code, doesn't work if instead of listing the file, I use the * (just like this:)
{% javascripts
'@MySiteBlogBundle/Resources/public/js/*'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
with the *, it works only depending on the pages which are displayed. I did all my javascipt test on class which are on my main twig template. And thoses class are displayed on all pages... So all test should be working.
Anyone ever had such probleme when using this * sign with assetic?
Thanks for any comment/help.
Upvotes: 1
Views: 1173
Reputation: 1
After few hours with the same issue, I realized you need to:
create symbolic links (A.K.A. symlinks) or copy of your bundles by command:
bin/console assets:install
or
bin/console assets:install --symlink
in your definitions, use bundles/mysiteblog/js/*
rather than @MySiteBlogBundle/Resources/public/js/*
(you will see your bundle path in WEB directory after Step 1.
Upvotes: 0
Reputation: 692
I noticed only two problems with assetic earlier.
First, in production mode you have to dump them (php app/console assetic:dump --env=prod) before using. Okay, this is not a problem but you shouldn't forget it.
Second, if you use the * sign to load all JavaScripts then the order of your scripts will be alphabetical and this can break a few dependencies among script files. This is the reason I usually don't use the * sign.
Upvotes: 3