Skip to content

Assetic fixes #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Assetic fixes #1991

wants to merge 3 commits into from

Conversation

oscherler
Copy link

Two additions to hopefully help newcomers:

  • The bundles option in the Assetic configuration defaults to [], it must be changed, one way or another;
  • Relative paths in CSS files don’t work anymore and the cssrewrite filter does not work with the @AsseticFooBundle syntax, so a workaround is proposed.

I have not included the other formats besides YAML for the config file because I’m not comfortable enough with them and the AsseticBundle Configuration Reference only includes YAML. I have not tested the PHP version of the example for the output parameter.

Of course, I will gladly update this based on suggestions.

It is empty by default on new Symfony installations, which prevents all the @AsseticFooBundle examples from working.
For the above example to work, you must either add your bundle to the list
of bundles that Assetic is allowed to handle (which is *none* in a default
Symfony installation), or remove the bundle list from the configuration
altogether:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't advocate removing the list entirely, as it mean AsseticBundle would scan all bundles for assetic tags, which is slow

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I didn’t know. Will fix.


# app/config/config.yml
assetic:
debug: "%kernel.debug%"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%kernel.debug% is the default value for the assetic.debug setting, so I think this line isn't needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the config like this in the standard distribution though so its in keeping with that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small detail either way, but what I'd love the most is to use the # ... in this spot:

assetic:
    # ...
    bundles:    [ AcmeFooBundle ]
    filters:
        # ...

Also, is this new note actually correct yet? My impression is that you don't need to add your bundle to the bundles configuration until you place a stylesheets or javascripts tag into a template that lives inside that bundle. If your stylesheets or javascripts tags are only in a template in app/Resources/views (even if you're referencing CSS/JS files that are in some bundle), then you don't need to add the bundle to the bundles key.

If I'm wrong, some please shout at me! :) I just wanted to make sure we were clear on that before merging.

Thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My impression is that you don't need to add your bundle to the bundles configuration until you place a stylesheets or javascripts tag into a template that lives inside that bundle.

I strongly suspect that you are correct. It makes a lot more sense to me now. I’ll make some tests next week and rewrite accordingly.

@weaverryan
Copy link
Member

ping! @oscherler :)

assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ AcmeFooBundle ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be [AcmeFooBundle]

@weaverryan
Copy link
Member

ping again! @oscherler :)

@oscherler
Copy link
Author

@weaverryan Hi. I’m super-busy right now, but if everything goes well I should be able to deal with this (and hopefully tackle a couple more things, since I’ve been using Symfony a lot lately) during February.

@oscherler
Copy link
Author

@weaverryan And I totally missed your previous ping. Sorry.

@oscherler
Copy link
Author

(By the way, to avoid confusion, I’m both oscherler and gm-olivier: silly me pushed the commits with the wrong git config).

@weaverryan weaverryan mentioned this pull request Feb 25, 2013
@weaverryan
Copy link
Member

Hi @oscherler!

Ok! A few notes:

  1. The comment you added about the cssrewrite filter and using the MyBundle syntax is very good, but needs to be applied to the 2.0 branch (since it affects that branch as well).

  2. The note about the assetic.bundles key is actually not quite right: you can refer to CSS/JS files that live inside a bundle without adding your bundle to this key. You only need to add your bundle to this key if the stylesheets or javascripts tag lives in a template that lives in that bundle.

So, here's what we're going to do :). I've opened a new PR - #2263 - against the 2.0 branch which includes your commit about the cssrewrite filter as well as a re-read of most of this chapter in general. After that is merged, we'll add the note about assetic.bundles.

Let me know if that works for you - the 2 things you've added here are indeed very important notes to have, so I appreciate you putting this together!

Thanks!

@weaverryan weaverryan closed this Feb 25, 2013
@stof
Copy link
Member

stof commented Feb 25, 2013

@weaverryan note that assetic.bundles also exist in 2.0. The difference is what the SE defines for it in its config files.

@oscherler
Copy link
Author

@weaverryan Sounds good to me. :)

So in the future, when I make a pull request, I target the 2.0 branch if it also applies to Symfony 2.0, and the 2.1 branch otherwise?

@wouterj
Copy link
Member

wouterj commented Feb 25, 2013

@oscherler when you are documenting a new feature, you choose the branch in which the feature was added (2.0 for Sf2.0.x, 2.1 for Sf2.1.x, master for Sf2.2.x (a 2.2 branch will be created in the coming weeks)). Otherwise, you choose the 2.0 branch.

Once in a week, all branches will be merged into each other which means that a bug fixed in the 2.0 branch will also be fixed in 2.1 and master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants