我看到错误消息关于一个文件,min.map,没有找到:

jQuery的jQuery -1.10.2.min。map正在触发404(未找到)


截图

这是怎么回事?


当前回答

如果你想获得不同版本的源地图文件,可以使用这个链接 http://code.jquery.com/jquery-x.xx.x.min.map

相反,x.xx.x输入您的版本号。

注意:一些链接,你得到这个方法,可能是坏的:)

其他回答

jQuery的新版本需要这个文件http://code.jquery.com/jquery-1.10.2.min.map

此文件的可用性描述在http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

更新:

jQuery 1.11.0/2.1.0

// sourceMappingURL注释不包含在压缩文件中。

我也遇到过同样的问题。我的原因是Grunt连接了我的JavaScript文件。

我使用了一个;\n作为分隔符,导致源路径映射到404。

所以dev tools在找jquery。min。map;而不是jquery.min.map。

我知道这不是最初问题的答案,但我确信还有其他人具有类似的Grunt配置。

可以通过删除该行来删除404

//@ sourceMappingURL=jquery-1.10.2.min.map

从jQuery文件的顶部。

jQuery文件的顶部看起来像这样。

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery-1.10.2.min.map
*/

把它改成

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license */

源映射的目的

Basically it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location. Developer tools (currently WebKit nightly builds, Google Chrome, or Firefox 23+) can parse the source map automatically and make it appear as though you're running unminified and uncombined files. (Read more on this here)

在遵循其他答案中的说明后,我需要从地图文件中剥离这个版本,以便为我工作。

例如:重命名

jquery-1.9.1.min.map

to

jquery.min.map

根据我对浏览器的理解,至少Chrome,默认情况下不会禁用源映射。这意味着应用程序的用户将在默认情况下触发此源映射请求。

您可以通过删除//@ sourceMappingURL=jquery.min来删除源映射。映射你的JavaScript文件。