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

Commit ed895df

Browse files
committed
Work around sourcemap issues with use of banner option
Related to Polymer/polymer#307 Root cause is gruntjs/grunt-contrib-uglify#22
1 parent bf5d775 commit ed895df

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

gruntfile.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* license that can be found in the LICENSE file.
55
*/
66
module.exports = function(grunt) {
7+
var temporary = require('temporary');
8+
var tmp = new temporary.File();
79

810
// recursive module builder
911
var path = require('path');
@@ -43,7 +45,7 @@ module.exports = function(grunt) {
4345
nonull: true
4446
},
4547
files: {
46-
'platform.concat.js': readManifest('build.json')
48+
'platform.concat.js': readManifest('build.json', [tmp.path])
4749
}
4850
}
4951
},
@@ -107,7 +109,21 @@ module.exports = function(grunt) {
107109
grunt.file.write(dest, JSON.stringify(destMap));
108110
});
109111

110-
grunt.registerTask('default', ['concat_sourcemap', 'uglify', 'sourcemap_copy:platform.concat.js.map:platform.min.js.map']);
112+
// Workaround for banner + sourceMap + uglify: https://github.com/gruntjs/grunt-contrib-uglify/issues/22
113+
grunt.registerTask('gen_license', function() {
114+
var banner = [
115+
'/* @license',
116+
grunt.file.read('LICENSE'),
117+
'*/'
118+
].join(grunt.util.linefeed);
119+
grunt.file.write(tmp.path, banner);
120+
});
121+
122+
grunt.registerTask('clean_license', function() {
123+
tmp.unlinkSync();
124+
});
125+
126+
grunt.registerTask('default', ['gen_license', 'concat_sourcemap', 'uglify', 'sourcemap_copy:platform.concat.js.map:platform.min.js.map', 'clean_license']);
111127
grunt.registerTask('docs', ['yuidoc']);
112128
grunt.registerTask('test', ['override-chrome-launcher', 'karma:platform']);
113129
grunt.registerTask('test-buildbot', ['override-chrome-launcher', 'karma:buildbot']);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"karma-safari-launcher": "*",
1515
"karma-script-launcher": "*",
1616
"karma-crbot-reporter": "*",
17-
"grunt-concat-sourcemap": "~0.3.0"
17+
"grunt-concat-sourcemap": "~0.3.0",
18+
"temporary": "~0.0.7"
1819
}
1920
}

0 commit comments

Comments
 (0)