In our Django project, we use Gulp to compile our assets, and then UglifyJS to minimize them. Throughout this process, we generate source maps that seem to work correctly.
The problem occurs when we use the Django static template tag to include our minified files. Say we have a mini JS file called ourapp.min.js . In our template, we will write:
<script src="{% static 'ourapp.min.js %}"></script>
which will be compiled into something like:
<script src="/ourstaticroot/ourapp.min.0123456789ab.js"></script>
(where 0123456789ab is the hash of the contents of the file)
The problem is that although the file has been renamed, our sourcemap still points to the old file name, so it suddenly becomes invalid. If we need to debug this page (say, using Sentry), it cannot find the source file, and it remains for us to debug the rounded file, which becomes a much more important task.
Does anyone know a good way around this? We would like to continue to use Gulp for our assets, as well as continue to use hashed file names, as this prevents the problems caused by caching obsolete asset files.
source share