Is it possible on Symfony2 use assets_version by file?
We are using assets_version and assets_version_format to
The following solution will append a timestamp instead of a version number. The important part is that he timestamp will only change when you clear your cache.
First create a compiler pass:
removeDefinition('assets._version__default');
$decorator = new DefinitionDecorator('assets.static_version_strategy');
$decorator->replaceArgument(0, time());
$container->setDefinition('assets._version__default', $decorator);
}
}
Then add it to your main bundle:
namespace App\Bundle;
use App\Bundle\DependencyInjection\Compiler\AssetCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new AssetCompilerPass());
}
}
This will only work on the default asset package. You would need to loop through the different package definitions you have set up if you are using that feature.
You would need to replace assets._version_
instead of assets._version__default