Map Preprocessed Code to Provider Code For Your Needs
Keep your client-side code debuggable and readable even with you have combined, minified or put together it. Utilize supply maps to map your supply rule to your put together rule.
- Utilize supply Maps to map code that is minified supply rule. You may then read and debug put together code with its initial supply.
- Only utilize preprocessors with the capacity of creating supply Maps.
- Verify that the internet host can serve supply Maps.
Begin with preprocessors
This short article describes just how to communicate with JavaScript supply Maps into the DevTools Sources Panel. For a very first breakdown of just what preprocessors are, how they may assist and exactly how supply Maps work, mind up to put up CSS & JS Preprocessors.
Make use of supported preprocessor
You should employ a minifier that is effective at creating maps that are source. For the many popular choices, see our preprocessor help part. For the view that is extended understand supply maps: languages, tools as well as other information wiki page.
Listed here types of preprocessors are generally 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 minified people. Afterward you make use of the originals to create breakpoints and move through rule. Meanwhile, Chrome is really operating your minified rule. Thus giving you the impression of operating a development web site in manufacturing.
Whenever operating supply Maps in DevTools, you will realize that the JavaScript is not put together and you may see most of the specific JavaScript files it references. It is utilizing supply mapping, but behind the scenes really operates the compiled code. Any errors, logs and breakpoints will map towards the dev rule for awesome debugging! Therefore in place you are given by it the impression you are operating a dev site in manufacturing.
Enable Source Maps in settings
Supply Maps are enabled by default (as of Chrome 39), however if you would like to double-check or allow them, first available DevTools and then click the settings cog . Under Sources, check Enable JavaScript Source Maps. You may additionally check Enable CSS Source Maps.
Debugging with Source Maps
When debugging your rule and Source Maps enabled, supply Maps will show in 2 places:
- Into the system (the web link to supply must be the initial file, perhaps not the one that is generated
- Whenever stepping through rule (backlinks in 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 looks quite similar to the //# sourceMappingURL property and it is really mentioned within the Source Map V3 specifications.
By like the after special comment in your rule, which is evaled, you’ll name evals and inline scripts and designs so they really appear as more rational names in your asian brides DevTools.
Navigate for this demo, then:
- Start the DevTools and go directly to the Sources panel.
- Enter in a filename in to the true name your rule: input field.
- Click the compile button.
- An alert will appear with the evaluated sum from the CoffeeScript supply.
In the event that you expand the Sources sub-panel you may now see a brand new file with all the custom filename you entered early in the day. In the event that you double-click to look at this file it will probably contain the compiled JavaScript for our original supply. Regarding the line that is last but, will soon be a // @sourceURL comment indicating just just what the initial supply file ended up being. This could easily significantly assistance with debugging when working with language abstractions.