twitter-bootstrap Bootstrap 尝试加载地图文件。如何禁用它?我需要这样做吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21773376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:02:04  来源:igfitidea点击:

Bootstrap trying to load map file. How to disable it? Do I need to do it?

twitter-bootstraptwitter-bootstrap-3

提问by dhblah

I'm recently playing with bootsrap3. I compiled it from sources and included distr js and css to my project. The thing is, I see in GH dev tools, that it's trying to get .map.css file. Why does it want to do so? How to disable it? Do I need to disable it? To not to have an error mark in dev tools, I added that map file, after which all styles are displayed as they defined in less files, which doesn't help me much.

我最近在玩 bootsrap3。我从源代码编译它并将 distr js 和 css 包含到我的项目中。问题是,我在 GH 开发工具中看到,它正在尝试获取 .map.css 文件。它为什么要这样做?如何禁用它?我需要禁用它吗?为了在开发工具中没有错误标记,我添加了该地图文件,之后所有样式都按照它们在较少文件中定义的方式显示,这对我没有多大帮助。

回答by user2779632

Delete the line /*# sourceMappingURL=bootstrap.css.map */from bootstrap.css

删除线/*# sourceMappingURL=bootstrap.css.map */bootstrap.css

回答by Dominic Zukiewicz

.map files allow a browser to download a full version of the minified JS. It is really for debugging purposes.

.map 文件允许浏览器下载完整版的缩小版 JS。它实际上是用于调试目的。

In effect, the .map missing isn't a problem. You only know it is missing, as the browser has had its Developer tools opened, detected a minified file and is just informing you that the JS debugging won't be as good as it could be.

实际上,缺少 .map 不是问题。你只知道它丢失了,因为浏览器打开了它的开发者工具,检测到一个缩小的文件,只是通知你 JS 调试不会像它应该的那么好。

This is why libraries like jQuery have the full, the minified and the map file too.

这就是为什么像 jQuery 这样的库也有完整的、缩小的和地图文件的原因。

See this article for a full explanation of .map files:

有关.map 文件的完整说明,请参阅本文:

回答by Nicolás Jofré

Remove the line /*# sourceMappingURL=bootstrap.css.map */in bootstrap.css

删除行/*# sourceMappingURL=bootstrap.css.map */bootstrap.css

If the error persists, clean the cache of the browser (CTRL + F5).

如果错误仍然存​​在,请清除浏览器的缓存 (CTRL + F5)。

回答by Shovalt

This only happens when you use the dev-tools, and won't happen for normal users accessing the production server.

这仅在您使用开发工具时发生,对于访问生产服务器的普通用户不会发生。

In any case, I found it useful to simply disable this behavior in the dev-tools: open the settings and uncheck the "Enable source maps" option.

无论如何,我发现在 dev-tools 中简单地禁用此行为很有用:打开设置并取消选中“启用源映射”选项。

There will no longer be an attempt to access map files.

将不再尝试访问地图文件。

回答by Avinash Kancharla

Delete the line "/*# sourceMappingURL=bootstrap.min.css.map */ "in following files.

删除"/*# sourceMappingURL=bootstrap.min.css.map */ "以下文件中的行。

  • css/bootstrap.min.css
  • css/bootstrap.css
  • css/bootstrap.min.css
  • css/bootstrap.css

To fetch the file path in Linux use the command find / -name "\*bootstrap\*"

要在 Linux 中获取文件路径,请使用以下命令 find / -name "\*bootstrap\*"

回答by Julian Mann

If you don't have the correct .map file and you don't want to edit lines in bootstrap.css you can create a dummy .map file.

如果您没有正确的 .map 文件并且不想编辑 bootstrap.css 中的行,您可以创建一个虚拟的 .map 文件。

In my case I was seeing the error:

就我而言,我看到了错误:

GET /bootstrap.css.map not found.

So I created an empty bootstrap.css.map in the /public directory and the error stopped.

所以我在 /public 目录中创建了一个空的 bootstrap.css.map 并且错误停止了。

回答by Sergio Perez

Delete/*# sourceMappingURL=bootstrap.min.css.map */ in css/bootstrap.min.css

删除/*# sourceMappingURL=bootstrap.min.css.map */ 在css/bootstrap.min.css

and delete/*# sourceMappingURL=bootstrap.css.map */ in css/bootstrap.css

并删除/*# sourceMappingURL=bootstrap.css.map */ 在css/bootstrap.css

回答by Steve

Deleting this line fixes it, but the problem is the boostrap files are in bower_componentsand not checked into source control.

删除这一行可以修复它,但问题是 boostrap 文件已在bower_components其中但未签入源代码管理。

So, every developer on the team will get the css file with the map reference when they pull the repo and do bower install(which is part of using a new repo).

因此,团队中的每个开发人员在拉取 repo 并执行bower install(这是使用新 repo 的一部分)时都会获得带有地图参考的 css 文件。

The file should not have the reference to a map that is not there.

该文件不应引用不存在的地图。

回答by SVANSKI

I had also warnings in Google Dev-Tools and I added only bootstrap.min.css.map file in the same folder, where bootstrap.min.css is.

我在 Google Dev-Tools 中也有警告,我只在 bootstrap.min.css 所在的同一文件夹中添加了 bootstrap.min.css.map 文件。

I have now no warnings more and You can find more Explanation here: https://github.com/twbs/bootstrap#whats-included

我现在没有更多的警告,你可以在这里找到更多的解释:https: //github.com/twbs/bootstrap#whats-included

I hope, I answered your Question.

我希望,我回答了你的问题。

回答by fw0213

For me, created an empty bootstrap.css.map together with bootstrap.css and the error stopped.

对我来说,创建了一个空的 bootstrap.css.map 和 bootstrap.css 并且错误停止了。