-
Notifications
You must be signed in to change notification settings - Fork 98
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
Update parameters based on vcs-status #39
Comments
@rvanlaak Dealing with the same problem I came up with the following solution:
imports:
- { resource: assets_version.php }
...
framework:
...
templating:
engines: ['twig']
packages:
style:
version_format: %%s?v=%%s
$container->loadFromExtension(
'framework',
array(
'templating' => array(
'packages' => array(
'style' => array(
'version' => substr(
file_exists(__DIR__.'/../../web/css/style.css')
? sha1_file(__DIR__.'/../../web/css/style.css')
: md5(time())
,
0,
6
)
),
...
)
),
)
); This way the assets version only changes if there are actual changes in the file. |
very nice @hacfi this is the central css file that gets finally generated from all others right? |
@rvanlaak ParameterHandler would not be able to get the asset version properly IMO. a far better way to deal with it is to use the cache busting feature in Assetic. See symfony/assetic-bundle#240 for the PR adding it in the bundle. |
@cordoval Yes, in my template I got {% stylesheets '@ProjectAppBundle/Resources/less/make.less' filter='lessphp,?yui_css' output="css/style.css" package="style" -%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %} I actually have more than this one css file but the main styling is that one big file. Instead of adding all the css/less files in my twig template I prefer doing this in the make.less. |
you can use env var to achive this one:
and of course, edit the composer.json as decribe in the README. |
Both using an env var and editing the composer.json do not seem appropriate to me, because then I'm unable to access it in for example my Twig templates. I solved this by a basic parameter in |
not sure if it could help you but i have a working easy example : |
@rvanlaak Making the variable available in Twig is about using the parameter. It is not related to the way you define it. and then, your original report was describing |
I'm using
Assetic
in combination withcompass
anduglifycss
to manage my assets. One of the configuration parameters of Assetic isassets_version
in order to handle cache busting.It would be nice if the ParameterHandler could update a parameter based on the current revision of a version control system (like svn or git). That would result in cache busting based on the code version, and would not bust the cache in case the code hasn't been updated but just some composer packages are updated.
The text was updated successfully, but these errors were encountered: