简体   繁体   English

grunt-contrib-concat中串联的.js文件的源映射错误

[英]Wrong source map for concatenated .js file in grunt-contrib-concat

Recently I faced a very nasty problem with source mapping using grunt-contrib-concat. 最近,我在使用grunt-contrib-concat进行源映射时遇到了一个非常讨厌的问题。 Grunt-contrib-concat concatenates several .js files into one and uses source-map module for source mapping. Grunt-contrib-concat将多个.js文件合并为一个,并使用source-map模块进行源映射。 So breakpoints in my code paused incorrectly both in Chrome and in VS Code. 因此,我的代码中的断点在Chrome和VS Code中均错误地暂停了。 (You know what is it, if you faced the same problem). (如果遇到相同的问题,您知道这是什么)。 My environment: Windows 10, VS Code with Debugger for Chrome extension, Chrome browser, Node.js project with grunt-contrib-concat dependency. 我的环境:Windows 10,带有适用于Chrome扩展程序的调试器的VS Code,Chrome浏览器,具有grunt-contrib-concat依赖项的Node.js项目。 It is very unefficient to debug your client-side code without correct breakpoints. 如果没有正确的断点,调试客户端代码效率非常低。

I have spent several hours to clear the problem, and finally I have found the solution. 我花了几个小时解决问题,最后找到了解决方案。 Problem was in concatenate minified .js files. 问题在于串联的缩小.js文件。 After these minified files line numbers in source map become wrong. 这些缩小的文件之后,源映射中的行号将变为错误。 So the solution is to exclude minified files and use normal instead. 因此,解决方案是排除缩小的文件并改用normal。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM