EvalSourceMapDevToolPlugin

This plugin enables more fine grained control of source map generation. It is also enabled automatically by certain settings of the devtool configuration option.

new webpack.EvalSourceMapDevToolPlugin(options);

This plugin wraps every module in an eval() call with its source map appended as a data URL, so no .map files are emitted. It accepts the same options object as the SourceMapDevToolPlugin, but the options that describe a separate source map file — filename, fileContext and publicPath — have nothing to name here and are ignored, as is a function-valued append.

Options

The following options are supported:

  • test (string RegExp function (module) => boolean [string, RegExp, function (module) => boolean]): Generate source maps for modules whose path matches the given value. There is no default: all modules get source maps unless test, include or exclude restrict them. It matches the module's own path, not the name of the chunk it ends up in, so it cannot be used to exclude a whole entry point or bundle.
  • include (string RegExp function (module) => boolean [string, RegExp, function (module) => boolean]): Include source maps for module paths that match the given value.
  • exclude (string RegExp function (module) => boolean [string, RegExp, function (module) => boolean]): Exclude modules that match the given value from source map generation.
  • 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.
  • ignoreList (string RegExp function (source) => boolean [string, RegExp, function (source) => boolean]): Decide whether to ignore source files that match the specified value in source maps.
  • module (boolean): Indicates whether loaders should generate source maps (defaults to true).
  • moduleFilenameTemplate (string): See output.devtoolModuleFilenameTemplate.
  • columns (boolean): Indicates whether column mappings should be used (defaults to true).
  • namespace (string): Namespace prefix to allow multiple webpack roots in the devtools. See output.devtoolNamespace.
  • noSources = false (boolean): Prevents the source file content from being included in the source map.
  • sourceRoot (string): Provide a custom value for the sourceRoot property in source maps.
  • debugIds (boolean): If true, unique ids will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds. See the TC39 sourcemap debug ID proposal for more details.

Examples

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

Basic Use Case

You can use the following code to replace the configuration option devtool: eval-source-map with an equivalent custom plugin configuration:

export default {
  // ...
  devtool: false,
  plugins: [new webpack.EvalSourceMapDevToolPlugin({})],
};

Exclude Vendor Maps

The following code would exclude source maps for any module coming from node_modules:

new webpack.EvalSourceMapDevToolPlugin({
  exclude: /node_modules/,
});
Edit this page·

9 Contributors

johnnyreillysimon04kinseyostbyzykmadhavarshneykokejamesgeorge007anshumanvEugeneHlushko