Search code examples
javascriptdebuggingminify

How to effectively debug minified JS files?


I've got problem debugging minified JS on production server.

While you can't catch some errors on your machine while testing dev/prod servers, there's an opportunity to send some frontend errors and exceptions from users to a special log.

When JS files are minified, debugging this code becomes a hell.
What are the best practices in performing such work?


Solution

  • So, after some time, we've continued to try and resolve damn trouble and we've stumbled upon this library that allows you to map your stack to unminified version of build.

    https://github.com/mozilla/source-map

    We needed this to embed to our internal system that collects error reports. There are also ready solutions across the web if don't need your own like we do:

    https://raygun.com/sourcemaps

    https://sourcemaps.info/