警告:-file- is being assigned a //# sourceMappingURL, but already has one

当为给定 JavaScript 源多次指定源映射时,会出现 JavaScript 警告 "-file- is being assigned a //# sourceMappingURL, but already has one."。

¥The JavaScript warning "-file- is being assigned a //# sourceMappingURL, but already has one." occurs when a source map has been specified more than once for a given JavaScript source.

信息

¥Message

Warning: -file- is being assigned a //# sourceMappingURL, but already has one.

错误类型

¥Error type

一个警告。JavaScript 的执行不会停止。

¥A warning. JavaScript execution won't be halted.

什么地方出了错?

¥What went wrong?

已为给定 JavaScript 源多次指定源映射。

¥A source map has been specified more than once for a given JavaScript source.

JavaScript 源通常会被组合和缩小,以便更有效地从服务器交付它们。使用 源映射,调试器可以将正在执行的代码映射到原始源文件。有两种方法可以分配源映射,即使用注释或为 JavaScript 文件设置标头。

¥JavaScript sources are often combined and minified to make delivering them from the server more efficient. With source maps, the debugger can map the code being executed to the original source files. There are two ways to assign a source map, either by using a comment or by setting a header to the JavaScript file.

示例

¥Examples

设置源映射

¥Setting source maps

使用文件中的注释设置源映射:

¥Setting a source map by using a comment in the file:

js
//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map

或者,你也可以为 JavaScript 文件设置标头:

¥Or, alternatively, you can set a header to your JavaScript file:

http
X-SourceMap: /path/to/file.js.map

也可以看看

¥See also