Skip to content

Commit 3f17503

Browse files
committed
Build/grunt: Custom banners for the various minified files
1 parent 953c49f commit 3f17503

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

grunt.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,38 @@ var rawList = allFiles.map(function(file) {
1010
});
1111

1212
var minify = {
13-
'dist/ui/minified/jquery-ui.min.js': ['<banner>', 'dist/ui/jquery-ui.js'],
13+
'dist/ui/minified/jquery-ui.min.js': ['<banner:meta.bannerAll>', 'dist/ui/jquery-ui.js'],
1414
// TODO adjust banner to get access to the list of included files
15-
'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['<banner>', 'dist/ui/i18n/jquery-ui-i18n.js']
15+
'dist/ui/minified/i18n/jquery-ui-i18n.min.js': ['<banner:meta.bannerI18n>', 'dist/ui/i18n/jquery-ui-i18n.js']
1616
};
1717
function minFile(file) {
1818
// TODO adjust banner to get access to the list of included files
1919
minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['<banner>', file];
2020
}
2121
allFiles.forEach(minFile);
22-
file.expand('ui/i18n/*.js').forEach(minFile);
2322

24-
config.init({
25-
pkg: '<json:package.json>',
26-
meta: {
27-
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
23+
var allI18nFiles = file.expand('ui/i18n/*.js');
24+
allI18nFiles.forEach(minFile);
25+
var i18nfiles = allI18nFiles.map(function(file) {
26+
return file.substring(8);
27+
});
28+
29+
function createBanner(files) {
30+
return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
2831
'<%= template.today("isoDate") %>\n' +
2932
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
3033
// TODO makes this banner only useful for the min-all task below...
31-
'* Includes: ' + rawList.join(', ') + '\n' +
34+
(files ? '* Includes: ' + files.join(', ') + '\n' : '') +
3235
'* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' +
33-
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
36+
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */';
37+
}
38+
39+
config.init({
40+
pkg: '<json:package.json>',
41+
meta: {
42+
banner: createBanner(),
43+
bannerAll: createBanner(rawList),
44+
bannerI18n: createBanner(i18nfiles)
3445
},
3546
concat: {
3647
'dist/ui/jquery-ui.js': allFiles,

0 commit comments

Comments
 (0)