简体   繁体   English

Chrome没有请求JS源地图,但Firefox确实如此

[英]Chrome not requesting JS source map, but Firefox does

I'm using webpack to build my client JS with the devtool: 'source-map' option, so my JS bundle ends in //# sourceMappingURL=app.bundle.js.map . 我正在使用webpack使用devtool devtool: 'source-map'选项构建我的客户端JS,所以我的JS包结束于//# sourceMappingURL=app.bundle.js.map When I open chrome devtools, Chrome shows a "Source Map detected" banner but does not actually show the original sources in the navigator. 当我打开chrome devtools时,Chrome会显示“检测到源地图”横幅,但实际上并未在导航器中显示原始来源。 My server access logs don't show any requests for the source map. 我的服务器访问日志不显示对源映射的任何请求。

When I open the same page with Firefox dev tools, it loads the source map exactly as expected. 当我使用Firefox开发工具打开同一页面时,它会按预期完全加载源地图。

All other assets load fine. 所有其他资产加载正常。 Clearing my browser cache doesn't help. 清除浏览器缓存无济于事。

Has anyone experienced this? 有没有人经历过这个? Is this a Chrome bug? 这是Chrome错误吗?

I have double-checked it on Google Chrome v53 it won't log any sourcemap-related requests (Network tab / Console) no matter what was response status 200 or 404. It means you need to make sure that your webserver is serving file properly. 我在Google Chrome v53 v53上仔细检查了它,无论响应状态为200还是404,它都不会记录任何与源地图相关的请求(网络选项卡/控制台)。这意味着您需要确保您的网络服务器正在正常提供文件。 For that you can simply open sourcemap url in the browser eg 为此,您只需在浏览器中打开sourcemap url即可

//# sourceMappingURL=sourcefile.js.map

localhost:3000/path/to/your/sourcefile.js.map

As alternative you can change your build so that sourcemap is inlined in js file. 作为替代方案,您可以更改构建,以便在js文件中内联sourcemap。 Then you don't need to fetch it from the server. 然后您不需要从服务器获取它。

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI...

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

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