I have a lot of javascript files, which goes through grunt uglify and gets minified individually, and further, I am performing grunt concat on these to get a single bundled minified file with source map.
Ex.
a.js, b.js, c.js
->Uglify->a.min.js, b.min.js,c.min.js->concat->bundle.min.js
With dev tools and source map, from bundle.min.js, I can trace back only up to a.min.js/b.min.js/c.min.js. Where as my goal is to use source map to trace back up to a.js/b.js/c.js.
Your requirement can be achieved, however you'll need to change the order of your tasks to the following instead:
a.js, b.js, c.js-->concat-->bundle.js-->uglify-->bundle.min.jsNote: The order of the tasks has been changed to concatenate the individual
.jsfiles before uglifying the resultant output.Why is it necessary to change the order of tasks?
Because grunt-contrib-uglify provides the
sourceMapInoption, whilst grunt-contrib-concat simply doesn't. Besides it's typical practice to concatenate files before uglifying them.The
sourceMapInoption is described as follows:Gruntfile.js
Your
Gruntfile.jscan be configured something like this:Notes:
The path value specified for the
concat.options.sourceMapNameanduglify.options.sourceMapInmust be the same, e.g.dist/js/bundle.map.The
concattask must run before theuglifytask.The
srcanddestpaths for both tasks will need to be defined as per your projects requirements.