Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing sourcemaps in Typescript + Webpack project

I've created a Github repo that has all the source code related to this question. I'm able to load build/index.html in the browser after running npm install. However, when I view the sources tab in Chrome, I don't see the source maps associated with the .tsx files.

Here's a screenshot of what I see: no-source-map

I've added sourceMap: true in my tsconfig.json as well as debug: true and devtool: "source-map" in my webpack.config.json. Any thoughts on what I'm missing here?

EDIT:

This might be a silly question, but do you have to use webpack-dev-server in order to see the sourcemaps?

like image 596
wmock Avatar asked Mar 14 '16 05:03

wmock


People also ask

What is Sourcemaps in webpack?

In a sense, source maps are the decoder ring to your secret (minified) code. Using Webpack, specifying devtool: "source-map" in your Webpack config will enable source maps, and Webpack will output a sourceMappingURL directive in your final, minified file.

How do webpack Sourcemaps work?

Webpack bundles multiple source files to one single bundle file. In some cases, there can be multiple bundle files. But in both cases, if there is an error in one of the source files, it is difficult to track it down from browser console. Source maps connect the bundle file with corresponding source files.

What is Sourcemap in TypeScript?

Explanation: TypeScript Map files are source map files that let tools map between the emitted JavaScript code and the TypeScript source files that created it. And these Source Map files will then help to debug the Typescript file instead of debugging the emitted JavaScript file.


2 Answers

Your tsconfig.json might be well.

Try in your webpack.config.js either devtool: "inline-source-map" or remove the two options od debug and devtool complete. In my case I don't need them.

like image 84
Matthias Avatar answered Oct 19 '22 00:10

Matthias


I had to add a filepath for the sourcemap file. Take a look at the output part of this webpack.config.js: https://github.com/nwinger/reactreduxtodo/blob/master/webpack.config.js

like image 43
Nicklas Pouey-Winger Avatar answered Oct 18 '22 23:10

Nicklas Pouey-Winger