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.
Launch the configuration in debug mode and then set a breakpoint in your code (a check mark appears).
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!
//# sourceMappingURL=main.js.map// Bundlers notation (to check if source map has been generated)
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
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:
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
- Common Mistakes to Avoid While Working with Vue.js
➥ React for beginners series
Originally published at www.linkedin.com on January 19, 2018.