Created
September 4, 2014 23:44
-
-
Save igordelorenzi/7662eb036f695adcd8ce to your computer and use it in GitHub Desktop.
Task for copying JavaScript Source Map files from vendor (and bower_components) to dist directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask('fixSourceMapping', function () { | |
var concat = grunt.config('concat'), | |
copy = grunt.config('copy'), | |
files = concat.generated.files, | |
i, src, sourceMapFiles = []; | |
for (i in files) { | |
if (files[i].dest === "dist/scripts/vendor.js") { | |
src = files[i].src; | |
break; | |
} | |
} | |
for (i in src) { | |
var file1 = src[i].replace(/.js/, '.map'); | |
var file2 = src[i] + '.map'; | |
if (grunt.file.exists(file1)) { | |
file1 = file1.replace(/client\//, ''); | |
sourceMapFiles.push(file1); | |
} | |
if (grunt.file.exists(file2)) { | |
file2 = file2.replace(/client\//, ''); | |
sourceMapFiles.push(file2); | |
} | |
} | |
copy.dist.files.push({ | |
expand: true, | |
flatten: true, | |
cwd: "client", | |
dest: "dist/scripts", | |
src: sourceMapFiles, | |
filter: 'isFile' | |
}); | |
grunt.config('copy', copy); | |
grunt.log.ok(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment