src/content/plugins/eval-source-map-dev-tool-plugin.mdx
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);
The following options are supported:
test (string RegExp function (asset) => boolean [string, RegExp, function (asset) => boolean]): Include source maps for modules based on their extension (defaults to .js and .css).
include (string RegExp function (asset) => boolean [string, RegExp, function (asset) => boolean]): Include source maps for module paths that match the given value.
exclude (string RegExp function (asset) => boolean [string, RegExp, function (asset) => boolean]): Exclude modules that match the given value from source map generation.
append (string|function): Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file.
Starting from version 5.84.0, webpack allows the append option to be a function that accepts path data and an asset info object as arguments, and returns a string.
(pathData: PathData, assetInfo?: AssetInfo) => string;
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).
protocol (string): Allows user to override default protocol (webpack-internal://)
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.
T> Setting module and/or columns to false will yield less accurate source maps but will also improve compilation performance significantly.
T> If you want to use a custom configuration for this plugin in development mode, make sure to disable the default one. I.e. set devtool: false.
The following examples demonstrate some common use cases for this plugin.
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({})],
};
The following code would exclude source maps for any modules in the vendor.js bundle:
new webpack.EvalSourceMapDevToolPlugin({
exclude: ["vendor.js"],
});