Skip to content

Commit

Permalink
Fix file paths in source maps for all directory levels
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Oct 21, 2013
1 parent d490ee9 commit 50a8c94
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Gruntfile.js
Expand Up @@ -97,10 +97,6 @@ module.exports = function(grunt) {
},

fixSourceMaps: {
options: {
srcBase: 'build',
destBase: 'build'
},
all: ['build/**/*.map']
},

Expand Down Expand Up @@ -155,11 +151,6 @@ module.exports = function(grunt) {

// Custom Grunt tasks
grunt.registerMultiTask('fixSourceMaps', function () {
var options = this.options({
destBase: '',
srcBase: ''
});

this.files.forEach(function (f) {
var result;
var sources = f.src.filter(function (filepath) {
Expand All @@ -170,9 +161,10 @@ module.exports = function(grunt) {
return true;
}
}).forEach(function (filepath) {
var base = path.dirname(filepath);
var sMap = grunt.file.readJSON(filepath);
sMap.file = path.relative(options.destBase, sMap.file);
sMap.sources = _.map(sMap.sources, path.relative.bind(path, options.srcBase));
sMap.file = path.relative(base, sMap.file);
sMap.sources = _.map(sMap.sources, path.relative.bind(path, base));

grunt.file.write(filepath, JSON.stringify(sMap));
// Print a success message.
Expand Down

0 comments on commit 50a8c94

Please sign in to comment.