Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Work around sourcemap issues with use of banner option
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Oct 10, 2013
1 parent bf5d775 commit ed895df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 18 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* license that can be found in the LICENSE file.
*/
module.exports = function(grunt) {
var temporary = require('temporary');
var tmp = new temporary.File();

// recursive module builder
var path = require('path');
Expand Down Expand Up @@ -43,7 +45,7 @@ module.exports = function(grunt) {
nonull: true
},
files: {
'platform.concat.js': readManifest('build.json')
'platform.concat.js': readManifest('build.json', [tmp.path])
}
}
},
Expand Down Expand Up @@ -107,7 +109,21 @@ module.exports = function(grunt) {
grunt.file.write(dest, JSON.stringify(destMap));
});

grunt.registerTask('default', ['concat_sourcemap', 'uglify', 'sourcemap_copy:platform.concat.js.map:platform.min.js.map']);
// Workaround for banner + sourceMap + uglify: https://github.com/gruntjs/grunt-contrib-uglify/issues/22
grunt.registerTask('gen_license', function() {
var banner = [
'/* @license',
grunt.file.read('LICENSE'),
'*/'
].join(grunt.util.linefeed);
grunt.file.write(tmp.path, banner);
});

grunt.registerTask('clean_license', function() {
tmp.unlinkSync();
});

grunt.registerTask('default', ['gen_license', 'concat_sourcemap', 'uglify', 'sourcemap_copy:platform.concat.js.map:platform.min.js.map', 'clean_license']);
grunt.registerTask('docs', ['yuidoc']);
grunt.registerTask('test', ['override-chrome-launcher', 'karma:platform']);
grunt.registerTask('test-buildbot', ['override-chrome-launcher', 'karma:buildbot']);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"karma-safari-launcher": "*",
"karma-script-launcher": "*",
"karma-crbot-reporter": "*",
"grunt-concat-sourcemap": "~0.3.0"
"grunt-concat-sourcemap": "~0.3.0",
"temporary": "~0.0.7"
}
}

0 comments on commit ed895df

Please sign in to comment.