gruntjs/grunt-contrib-concat

Concatenating multiple files with sourcemaps

leigeber opened this issue · 2 comments

When joining two files that were previously minified with sourcemaps everything almost works perfectly but the trailing sourcemap declarations from the sources, for instance //# sourceMappingURL=maps/script.js.map ends up becoming just // on its own line which throws off the sourcemapping for any files after the first concatenated file.

If I remove the blank comment lines from the output everything seems to click. Is there a reason for not removing the entire sourcemap comment?

Here is the input for instance.

JavaScript 1
//# sourceMappingURL=maps/one.js.map
JavaScript 2
//# sourceMappingURL=maps/two.js.map

Here is what concat is doing.

JavaScript 1
//
JavaScript 2
//
//# sourceMappingURL=maps/script.js.map

Here is what works.

JavaScript 1
JavaScript 2
//# sourceMappingURL=maps/script.js.map

+1 I just ran across the same issue. I was concatenating multiple CSS files that were already minified and it successfully removed the source map reference but left the "/* */" which threw off the rest of the source maps.

I thought stripBanners would take care of this, but it doesn't. This bug has always existed as far as I can tell. I tried with 1.0 and 0.5.1 and 0.5.0.

@leigeber I think I'm having a similar concat problem, breakpoints don't work on the last js file I concat (or maybe more), I tried the proposed fix and didn't have much luck with that as well. I'm still investigating.