Map Preprocessed Code to Provider Code For You Personally

Maintain your client-side rule debuggable and readable even with you have combined, minified or put together it. Use supply maps to map your supply code to your put together rule.

  • Utilize supply Maps to map code that is minified supply rule. After that you can read and debug put together rule in its initial supply.
  • Only utilize preprocessors with the capacity of producing supply Maps.
  • Verify that your particular web host can provide Source Maps.

Begin with preprocessors

This informative article describes simple tips to communicate with JavaScript supply Maps within the DevTools Sources Panel. For a overview that is first of preprocessors are, how they may assist and exactly how provider Maps work, mind up to put up CSS & JS Preprocessors.

Make use of a supported preprocessor

You should utilize a minifier which is effective at creating source maps. When it comes to many options that are popular see our preprocessor help area. For the view that is extended look at Source maps: languages, tools as well as other information wiki page.

The next types of preprocessors can be found in combination with supply Maps:

Supply Maps in DevTools Sources panel

Source Maps from preprocessors cause DevTools to load your initial files as well as your ones that are minified. Afterward you make use of the originals to create breakpoints and move through rule. Meanwhile, Chrome is obviously operating your minified rule. Thus giving you the impression of running mail order bride a development web site in production.

Whenever source that is running in DevTools, you are going to realize that the JavaScript is not put together and you will see all of the specific JavaScript files it references. This can be utilizing supply mapping, but behind the scenes really operates the code that is compiled. Any mistakes, logs and breakpoints will map to your dev rule for awesome debugging! Therefore in effect it offers you the illusion that you are managing a dev web web site in production.

Enable Source Maps in settings

Supply Maps are enabled by standard (as of Chrome 39), however if you would like to double-check or allow them, first open DevTools and then click the settings cog . Under Sources, check Enable JavaScript Source Maps. You might additionally check Enable CSS Source Maps.

Debugging with Source Maps

Whenever debugging your rule and Source Maps enabled, supply Maps will show in 2 places:

  1. Into the system (the hyperlink to supply must be the original file, perhaps perhaps not the one that is generated
  2. Whenever stepping through rule (backlinks when you look at the call stack should start the initial supply file)

DisplayName and@sourceURL

The@sourceURL allows you to make development much easier when working with evals while not part of the source Map spec. This helper appears virtually identical in to the //# sourceMappingURL property and it is really mentioned when you look at the Source Map V3 specifications.

By like the following special comment in your rule, that will be evaled, you can easily name evals and inline scripts and designs so that they appear much more rational names in your DevTools.

Navigate to the demo, then:

  • Start the DevTools and go directly to the Sources panel.
  • Type in a filename to the title your rule: input industry.
  • Click the compile switch.
  • An alert will appear with the evaluated sum from the CoffeeScript supply.

In the event that you increase the Sources sub-panel you may now see a brand new file using the custom filename you joined early in the day. In the event that you double-click to see this file it’s going to contain the compiled JavaScript for our initial supply. Regarding the final line, but, is likely to be a // @sourceURL comment indicating just just what the initial supply file had been. This could easily significantly assistance with debugging whenever using language abstractions.