Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt Uglify - How to create a source map for debugging?

I'm using grunt in a project and created tasks to minify and concat many .js files.

I'm now trying to figure out how to create a source map out of them with Uglify so the other team can easily analyze the code in the console.

Part of my Gruntfile (in coffee) looks like these two:

        uglify:
        options:
            mangle: false

/

    grunt.registerTask 'devmin', ['clean', 'concurrent:transform', 'useminPrepare', 'concat', 'uglify', 'usemin', 'copy:build', 'server', 'watch:dist'] # Dev - minifies files

So, when I run "grunt devmin" on terminal I'll have minified versions but I can't figure out how to create a related sourcemap to them for debugging purposes.

Anyone's got a hint??

Thank you!

like image 230
lol Avatar asked Oct 22 '13 14:10

lol


1 Answers

There are various source map properties on the options object that you can set.

You probably want the "sourceMap" property, which is the file name of the source map to output e.g.

    uglify:
        options:
            sourceMap: 'mymap.map'

sourceMap can also be a function, where the first parameter is the output path of the file that you are minifying.

like image 135
Dan Avatar answered Nov 03 '22 18:11

Dan