diff --git a/gruntfile.js b/gruntfile.js index 99146ba..9d6fa67 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -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'); @@ -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]) } } }, @@ -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']); diff --git a/package.json b/package.json index ce7260f..d0d41b9 100644 --- a/package.json +++ b/package.json @@ -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" } }