kriswallsmith / assetic

Asset Management for PHP
MIT License
3.75k stars 559 forks source link

CacheBustingWorker and Twig extension not producing correct links #481

Open danaki opened 10 years ago

danaki commented 10 years ago

I'm using Silex:

        "kriswallsmith/assetic": "1.2.*@dev",
        "mheap/Silex-Assetic": "dev-master@dev",

App:

        $app->register(new AsseticServiceProvider(), [
            'assetic.path_to_web'   => $this['assetic.path_to_web'],
            'assetic.options'       => [
                'debug'                 => true,
                'auto_dump_assets'      => true,
            ],
        ]);

        $app['assetic.factory'] = $app->share(
            $app->extend('assetic.factory', function ($af, $app) {
                $af->addWorker(new \Assetic\Factory\Worker\CacheBustingWorker());
                return $af;
            })
        );

layout.twig:

        {% javascripts
                'assets/js/jquery-1.7.1.min.js'
                'assets/js/common.js'
                'assets/js/jcode.js'
                output='assets/cache/js/*'
                %}
            <script src="{{ asset_url }}"></script>
        {% endjavascripts %}

Twig produces links similar to:

<script src="assets/cache/js/cac3561_jquery-1.7.1.min_1-cb9c333.js">
<script src="assets/cache/js/cac3561_common_2-f881f73.js"></script>
<script src="assets/cache/js/cac3561_jcode_3-ff48c95.js"></script>

but if I ls:

zerg:js root# ls
cac3561-f274bd5.js cac3561-f274bd5_jquery-1.7.1.min_1-cb9c333.js cac3561-f274bd5_common_2-f881f73.js cac3561-f274bd5_jcode_3-c902ece.js

e.g. "-f274bd5" is missing, causing 404.

If I put debug => 'false' to assetic.options it produces:

<script src="assets/cache/js/cac3561-a6bc3e4.js"></script>

which also not found because only cac3561-f274bd5.js is generated in the filesystem. This time "-f274bd5" part is missing in the link and "-a6bc3e4" part is missing on the filesystem.

Thank you.

barryvdh commented 10 years ago

I am having the same issue, using Laravel (and a Service Provider based on mheap/Silex-Assetic for Laravel). Generated files: style2-1357c77_colorbox_1-9626f58.css style2-1357c77_test_2-0c60760.css Linked files in Twig style2_colorbox_1-9626f58.css style2_test_2-0c60760.css

When debug=false, the links are working. I can overcome this by just disabling cachebusting in debug mode, but is is strange it doesn't work.

enoshixi commented 10 years ago

+1