Stop Painful JavaScript Debug and Embrace Intellij with Source Map

Jan 19, 2018 · 3 min read
Picture by @worthyofelegance from Unsplash

I prefer to use IntelliJ to debug JavaScript instead of using browser tools. It’s for sure much more convenient and effective.

Let’s use projects bundled with Browserify and Webpack (no matter the framework).

First, install the JetBrains IDE Support Chrome extension. This will bind the browser debugger environment with IntelliJ in real-time.

Then, let’s open up our IDE and create a JavaScript Debug run configuration. Only two inputs to fill: your app running URL (local or remote) and JS files root directory Remote URL.

Launch the configuration in debug mode and then set a breakpoint in your code (a check mark appears).

Your app will be launched on Chrome in debug mode.

Bundlers help to merge sources into a single JS file. By default, there are no ways to perform the reverse action to debug from sources. Except if you ask your bundler to generate a source map file and link it to the bundled file.

// General notation, comment sign must be included! 
// Bundlers notation (to check if source map has been generated)
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ....

Activate source map generation in bundlers is straightforward for both bundlers. Enable debug mode in Browserify or set devtool value in Webpack configuration.

Webpack can generate source map for a production environment in an optimized way.

The debug configuration in IntelliJ is a bit different with webpack-dev-server, bundled files are deployed on webpack:///.

To debug the app, the project Remote URL must be set to this value (do not omit the dot). Note the JS files root directory Remote URL still on localhost.

References about this topic

If you encounter any troubles with debug configuration and Webpack, take a look at this JetBrains post:

For complete information about how source map works read Mozilla documentation. To see what source map file looks like, read this blog post.

Thank you for reading, I hope you enjoyed reading this article and it will help

If you found this article useful, please click on the 👏 button a few times to make others find the article and to show your support! 👊

Don’t forget to follow me to get notified of my upcoming articles 🙏

Check out my Other Articles

Originally published at on January 19, 2018.

JavaScript news and opinion.


JavaScript news and opinion.


Written by

Avid learner about web development 🔍 and writer ✍️ for sharing tips and tricks — Full-Stack Developer @SmarAdServer ➕


JavaScript news and opinion.