aboutsummaryrefslogtreecommitdiffstats
path: root/grunt.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-03-06 20:15:51 +0100
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-03-06 20:15:51 +0100
commitcc3b08df2d8be44a72977d33f042bafa0e21de13 (patch)
treea6a86c75c9c7416fd70448ff4121312898ff12d1 /grunt.js
parent02981c7c4005143285c4012f2d15dc24ccaf6725 (diff)
downloadjquery-ui-cc3b08df2d8be44a72977d33f042bafa0e21de13.tar.gz
jquery-ui-cc3b08df2d8be44a72977d33f042bafa0e21de13.zip
Build/grunt: Minify CSS files, using sqwish.
Diffstat (limited to 'grunt.js')
-rw-r--r--grunt.js53
1 files changed, 41 insertions, 12 deletions
diff --git a/grunt.js b/grunt.js
index 45deca7bd..44a49a372 100644
--- a/grunt.js
+++ b/grunt.js
@@ -1,13 +1,10 @@
/*global config:true, task:true*/
var coreFiles = 'jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js'.split(', ');
-var allFiles = coreFiles.map(function(file) {
+var uiFiles = coreFiles.map(function(file) {
return 'ui/' + file;
}).concat(file.expand('ui/*.js').filter(function(file) {
return coreFiles.indexOf(file.substring(3)) === -1;
}));
-var rawList = allFiles.map(function(file) {
- return file.substring(3);
-});
var minify = {
'dist/ui/minified/jquery-ui.min.js': ['<banner:meta.bannerAll>', 'dist/ui/jquery-ui.js'],
@@ -16,19 +13,23 @@ var minify = {
function minFile(file) {
minify['dist/' + file.replace(/\.js$/, '.min.js').replace(/ui\//, 'ui/minified/')] = ['<banner>', file];
}
-allFiles.forEach(minFile);
+uiFiles.forEach(minFile);
var allI18nFiles = file.expand('ui/i18n/*.js');
allI18nFiles.forEach(minFile);
-var i18nfiles = allI18nFiles.map(function(file) {
- return file.substring(8);
-});
+
+// TODO move core to the front, theme to the end, exclude all and base
+var cssFiles = file.expand('themes/base/*.css');
function createBanner(files) {
+ // strip folders
+ var fileNames = files && files.map(function(file) {
+ return file.replace(/.+\/(.+)$/, '$1');
+ });
return '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= template.today("isoDate") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
- (files ? '* Includes: ' + files.join(', ') + '\n' : '') +
+ (files ? '* Includes: ' + fileNames.join(', ') + '\n' : '') +
'* Copyright (c) <%= template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */';
}
@@ -37,14 +38,21 @@ config.init({
pkg: '<json:package.json>',
meta: {
banner: createBanner(),
- bannerAll: createBanner(rawList),
- bannerI18n: createBanner(i18nfiles)
+ bannerAll: createBanner(uiFiles),
+ bannerI18n: createBanner(allI18nFiles),
+ bannerCSS: createBanner(cssFiles)
},
concat: {
- 'dist/ui/jquery-ui.js': allFiles,
+ 'dist/ui/jquery-ui.js': uiFiles,
'dist/ui/i18n/jquery-ui-i18n.js': 'ui/i18n/*.js'
},
min: minify,
+ css_min: {
+ dist: {
+ src: ['<banner:meta.bannerCSS>'].concat(cssFiles),
+ dest: 'dist/themes/base/minified/jquery-ui.min.css'
+ }
+ },
zip: {
dist: {
src: [
@@ -107,5 +115,26 @@ task.registerBasicTask('zip', 'Create a zip file for release', function(data) {
log.writeln("Wrote " + files.length + " files to " + data.dest);
});
+task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( data ) {
+ var files = file.expand( data.src );
+ // Get banner, if specified. It would be nice if UglifyJS supported ignoring
+ // all comments matching a certain pattern, like /*!...*/, but it doesn't.
+ var banner = task.directive(files[0], function() { return null; });
+ if (banner === null) {
+ banner = '';
+ } else {
+ files.shift();
+ }
+ var max = task.helper( 'concat', files );
+ // Concat banner + minified source.
+ var min = banner + require('sqwish').minify( max, false );
+ file.write( data.dest, min );
+ if ( task.hadErrors() ) {
+ return false;
+ }
+ log.writeln( 'File "' + data.dest + '" created.' );
+ task.helper( 'min_max_info', min, max );
+});
+
task.registerTask('default', 'lint qunit');
task.registerTask('release', 'concat min zip');