Skip to content

Commit f161c6d

Browse files
committed
Clean up banner option.
1 parent bbe1da0 commit f161c6d

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

tasks/lib/uglify.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ var assign = require('object.assign');
1515
var uriPath = require('uri-path');
1616
var getOutputOptions;
1717

18+
// Converts \r\n to \n
19+
function normalizeLf(string) {
20+
return string.replace(/\r\n/g, '\n');
21+
}
22+
1823
exports.init = function(grunt) {
1924
var exports = {};
2025

@@ -228,8 +233,8 @@ exports.init = function(grunt) {
228233
source_map: null
229234
};
230235

231-
if (options.banner && options.sourceMap) {
232-
outputOptions.preamble = options.banner;
236+
if (options.banner) {
237+
outputOptions.preamble = normalizeLf(options.banner);
233238
}
234239

235240
if (options.screwIE8 === false) {

tasks/uglify.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ module.exports = function(grunt) {
6666
});
6767
var log = reportFacility(grunt, options);
6868

69-
// Process banner.
70-
var banner = normalizeLf(options.banner);
7169
var footer = normalizeLf(options.footer);
7270
var mapNameGenerator, mapInNameGenerator;
7371
var createdFiles = 0;
@@ -171,11 +169,6 @@ module.exports = function(grunt) {
171169
// Concat minified source + footer
172170
var output = result.min + footer;
173171

174-
// Only prepend banner if uglify hasn't taken care of it as part of the preamble
175-
if (!options.sourceMap) {
176-
output = banner + output;
177-
}
178-
179172
// Write the destination file.
180173
grunt.file.write(f.dest, output);
181174

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// banner without sourcemap
2+
23
function longFunctionC(a,b){return longNameA+longNameB+a+b}var longNameA=1,longNameB=2,result=longFunctionC(3,4);

0 commit comments

Comments
 (0)