34

Is it possible to add a local SourceMap? I have a Website, which I cannot modify, containing compressed (closure) JavaScript. I have a local JavaScript-SourceMap belonging to that file. Is there any way to tell GoogleChrome (or any other browser) to add a SourceMap before/after the page loads?

3
  • See developers.google.com/chrome-developer-tools/docs/… for how the location of the source map is found. Commented Feb 11, 2014 at 16:51
  • I don't think you can reference local files there? Commented Feb 11, 2014 at 19:12
  • 1
    Maybe you can use a Chrome extension to intercept the HTTP request for the JavaScript and insert the X-SourceMap header? Still not sure if it will work with a file:// URL though :( Commented Feb 15, 2014 at 18:18

1 Answer 1

12

You cannot point to file containing the map. You can however host your map locally and then point to localhost address. In the javascript source file there also must not be

//# sourceMappingURL=...

comment presented since than Chrome DevTools won't load the sourcemap if it is different than specified in the URL.

Sign up to request clarification or add additional context in comments.

4 Comments

in chrome you can right click the source file and select add source map...
@KennyXu Do you know if it's still available? I cannot see UI to add sourcemap
@Kazuki In the Sources tab, select the bundled .js file you want (e.g. app.js), then right click in the pane showing that bundled file's source code. That's where you'll see the "Add source map..." option.
Ahh, I was right clicking on the filename. It seems right clicking on the source code was the key. Thanks for help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.