Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use grunt-UglifyJS and sourcemaps?

I'm trying to make sourcemaps to play nice while i'm using Grunt and UglifyJS Grunt task.

Here is the current task:

uglify: {
  dist: {
    options: {
      sourceMap: function(path) {
        return path + ".map";
      },
    },
    files: {
      'dist/video.min.js': [ 'javascripts/video.js' ]
    }
  }
}

What's the problem?

The sourcemap is generated but Chrome is searching for the sourcemap in the wrong location ( that is dist/dist/video.min.js.map). I know this because i get 404 in console.

So I edited dist/video.min.js and changed sourceMappingURL to point to correct location. Now, the sourcemap is loaded but is looking for video.js in completely wrong place: dist/javascripts/video.js (that dist again!)

So basically now i'm out of any ideas, just poking the gruntfile with no luck.

Any ideas? Thanks!

like image 719
Ionuț Staicu Avatar asked Aug 05 '13 16:08

Ionuț Staicu


1 Answers

It seems that http://github.com/gruntjs/grunt-contrib-uglify/issues/71 is a potential fix.

Bummer, i always find the solution after i post on SO. This place is magic!

like image 93
Ionuț Staicu Avatar answered Oct 31 '22 14:10

Ionuț Staicu