简体   繁体   English

在 chrome 开发工具中加载单独的源映射文件

[英]Load separate sourcemap file in chrome dev tools

Is it possible to load an external source-map file (JSON), not included in the minified JS file used on a website?是否可以加载不包含在网站上使用的缩小 JS 文件中的外部源映射文件 (JSON)?

So far the only ways I know of to include a source-map for a particular js file is to either inline it, add a link in comments or set the path in HTTP header.到目前为止,我所知道的包含特定 js 文件的源映射的唯一方法是内联它,在注释中添加链接或在 HTTP header 中设置路径。

So I wonder - is it possible to load a source-map file that can't be accessed via HTTP?所以我想知道 - 是否可以加载无法通过 HTTP 访问的源映射文件? For instance - load it from my local drive, and point it to the js file it is supposed to be mapping?例如 - 从我的本地驱动器加载它,并将其指向它应该映射的 js 文件?

Cheers干杯

I know question is old, but had it myself nevertheless. 我知道问题已经过时了,但是我自己也有。 Here's how you do it in Chromium 63 以下是您在Chromium 63中的使用方法

添加源地图

  1. Open Debugger 打开调试器
  2. Right-click in source code area 在源代码区域中单击鼠标右键
  3. Select "Add source map…" 选择“添加源地图...”
  4. Enter URL to source map file 输入源映射文件的URL
    • if browser is able to download it and process it then sources appear as entry in source tree. 如果浏览器能够下载并处理它,则源在源树中显示为条目。

PS built with hidden source (separate files, no source comment) 用隐藏源构建的PS(单独的文件,没有源注释)

PPS does not matter where files are hosted, because it is URL. PPS与托管文件的位置无关,因为它是URL。 Must be accessible by browser. 必须可以通过浏览器访问。

August 2022, Chrome 104: 2022 年 8 月,Chrome 104:

  1. Open Chrome Dev Tools打开 Chrome 开发工具
  2. Go to " Sources " tab Go 到“来源”选项卡
  3. Find the .js file you are looking for.找到您要查找的.js文件。 Click on it.点击它。
  4. Right click somewhere ON THE SOURCE .右键单击上的某处。
  5. Find "Add source map..." option there.在那里找到“添加源 map ...”选项。

在此处输入图像描述

(I first wrote this as a comment to the other answer , but @christian-vincenzo-traina suggested having it as a separate answer.) (我首先将其写为对另一个答案的评论,但@christian-vincenzo-traina建议将其作为单独的答案。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM