返回介绍

EvalSourceMapDevToolPlugin

发布于 2019-05-27 04:54:32 字数 3200 浏览 1337 评论 0 收藏 0

This plugin enables more fine grained control of source map generation. It is an alternative to the devtool configuration option.

new webpack.EvalSourceMapDevToolPlugin(options)

Options

The following options are supported:

  • test (string|regex|array): Include source maps for modules based on their extension (defaults to .js and .css).
  • include (string|regex|array): Include source maps for module paths that match the given value.
  • exclude (string|regex|array): Exclude modules that match the given value from source map generation.
  • filename (string): Defines the output filename of the SourceMap (will be inlined if no value is provided).
  • append (string): Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending.
  • moduleFilenameTemplate (string): See output.devtoolModuleFilenameTemplate.
  • sourceURLTemplate: Define the sourceURL default: webpack-internal:///${module.identifier}
  • module (boolean): Indicates whether loaders should generate source maps (defaults to true).
  • columns (boolean): Indicates whether column mappings should be used (defaults to true).
  • protocol (string): Allows user to override default protocol (webpack-internal://)

T> Setting module and/or columns to false will yield less accurate source maps but will also improve compilation performance significantly.

Examples

The following examples demonstrate some common use cases for this plugin.

Exclude Vendor Maps

The following code would exclude source maps for any modules in the vendor.js bundle:

new webpack.EvalSourceMapDevToolPlugin({
  filename: '[name].js.map',
  exclude: ['vendor.js']
})

Setting sourceURL

Set a URL for source maps. Useful for avoiding cross-origin issues such as:

A cross-origin error was thrown. React doesn't have access to the actual error object in development. See https://fb.me/react-crossorigin-error for more information.

The option can be set to a function:

new webpack.EvalSourceMapDevToolPlugin({
  sourceURLTemplate: module => `/${module.identifier}`
})

Or a substition string:

new webpack.EvalSourceMapDevToolPlugin({
  sourceURLTemplate: '[all-loaders][resource]'
})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文