source mapping with assetic in symfony2 source mapping with assetic in symfony2 symfony symfony

source mapping with assetic in symfony2


The problem with your example is that you are combining two sources into one, and from two different locations. If you look at the generated script tags in your dev environment, you'll see that the two routes are something like:

<script src="/js/ed5a632_jquery.min_1.js"></script><script src="/js/ed5a632_jquery.mobile.min_2.js"></script>

Assetic does not create matching routes for source maps, so these files now have invalid sourceMappingURL values - hence your 404.

One solution is to export the source maps (and sources) to a location relative to the dynamic routes using the assetic.assets configuration:

ref: https://github.com/symfony/symfony/pull/848

e.g. config.yml

assetic:  assets:    map1:      input: "%kernel.root_dir%/../src/path/to/jquery.min.map"      output: js/jquery.min.map    src1:      input: "%kernel.root_dir%/../src/path/to/jquery.js"      output: js/jquery.js

This will ensure the sourceMappingURL is hit, but it's a bit of a mess having all this separate from your template code.

If you can live with two separate assets in your production site, a much simpler solution is to just reference the two assets individually, e.g.

<script src="{{ asset('bundles/bmatznerjquery/js/jquery.min.js') }}"></script><script src="{{ asset('bundles/bmatznerjquerymobile/js/jquery.mobile.min.js') }}"></script>

After running the assets:install console command, these scripts should link just fine to the source maps and source files.