A source map provides a mapping between the original and the build source code.
The bundler that combined/minified the source code creates the source map
This is an important element used in a debug session in order to be able to stop at breakpoint.
The location coordinates are by line and column number in the source map.
With source maps, it is possible to single step through or set breakpoints in the original source.
Source maps can be generated with two kinds of inlining:
Source maps works for styling as well. See CSS - Source Map
If no source map exists for the original source or if the source map is broken and cannot successfully map between the source and the generated JavaScript, then breakpoints show up as unverified (gray hollow circles).
The devtool option controls if and how source maps are generated for devtool.
module.exports = {
mode: 'development',
entry: './js/index.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
};
where the devtool value may be:
Running webpack through:
webpack -d
where -d is shorthand for –debug –devtool source-map –output-pathinfo
Hash: db8af9ffcce7bc166a1d
Version: webpack 3.6.0
Time: 2678ms
Asset Size Chunks Chunk Names
bundle.js 1.07 MB 0 [emitted] [big] main
bundle.js.map 1.09 MB 0 [emitted] main
See:
The sourceMap option of the compiler controls the generation of a source map.
{
"compilerOptions": {
..........
"sourceMap": true,
........
}
The devtool is a set of web developer tools embedded in every browser