X-Git-Url: http://git.roojs.org/?p=bootswatch;a=blobdiff_plain;f=Gruntfile.js;h=f5b0c10d3965b30fe48a5cd2adc21867262cc906;hp=4d8fcf7bef63a8408c459ff6839708f804513285;hb=refs%2Fheads%2Fgh-pages;hpb=fc592d52f7b35444bd365df54923fb07e25a264c diff --git a/Gruntfile.js b/Gruntfile.js index 4d8fcf7..f5b0c10 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,12 +2,12 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-clean'); - // grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); // Project configuration. grunt.initConfig({ - builddir: 'build', pkg: grunt.file.readJSON('package.json'), + builddir: '.', meta: { banner: '/**\n' + ' * <%= pkg.description %>\n' + @@ -16,52 +16,74 @@ module.exports = function (grunt) { ' * @link <%= pkg.homepage %>\n' + ' * @license <%= pkg.license %>' + ' */' }, - build: { - amelia: {}, cerulean:{}, cosmo:{}, cyborg:{}, journal:{}, readable:{}, - shamrock:{}, simplex:{}, slate:{}, spacelab:{}, spruce:{}, superhero:{}, - united:{} + swatch: { + amelia:{}, cerulean:{}, cosmo:{}, cyborg:{}, flatly:{}, journal:{}, + readable:{}, simplex:{}, slate:{}, spacelab:{}, united:{}, yeti: {}, + custom:{} }, clean: { - build: { - src: ['*/build.less', '*/build-responsive.less', - '!global/build.less', '!global/build-responsive.less'] - } + build: { + src: ['*/build.less', '!global/build.less'] + } }, concat: { dist: { - src: ['global/build.less'], + src: [], dest: '' } }, recess: { dist: { options: { - compile: true + compile: true, + compress: false }, files: {} } - }, - min: { - build: { - src: ['', ''], - dest: '<%= builddir %>/<%= pkg.name %>.min.js' - } } }); - grunt.registerMultiTask('build', 'build a theme', function() { - var theme = this.target; - grunt.log.writeln('building theme ' + this.target); + grunt.registerTask('none', function() {}); + + grunt.registerTask('build', 'build a regular theme', function(theme, compress) { + var compress = compress == undefined ? true : compress; - var concatDest = theme + '/build.less'; + var concatSrc; + var concatDest; + var recessDest; + var recessSrc; + var files = {}; + var dist = {}; + concatSrc = 'global/build.less'; + concatDest = theme + '/build.less'; + recessDest = '<%=builddir%>/' + theme + '/bootstrap.css'; + recessSrc = [ theme + '/' + 'build.less' ]; - var recessDest = theme + '/' + theme + '.css'; - var recessSrc = [ theme + '/' + 'build.less' ]; + dist = {src: concatSrc, dest: concatDest}; + grunt.config('concat.dist', dist); + files = {}; files[recessDest] = recessSrc; + grunt.config('recess.dist.files', files); + grunt.config('recess.dist.options.compress', false); + + grunt.task.run(['concat', 'recess:dist', 'clean:build', + compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap.min.css':'none']); + }); + + grunt.registerTask('compress', 'compress a generic css', function(fileSrc, fileDst) { + var files = {}; files[fileDst] = fileSrc; + grunt.log.writeln('compressing file ' + fileSrc); - grunt.config('concat.dist.dest', concatDest); - var files = {}; files[recessDest] = recessSrc; grunt.config('recess.dist.files', files); + grunt.config('recess.dist.options.compress', true); + grunt.task.run(['recess:dist']); + }); - grunt.task.run(['concat', 'recess:dist', 'clean:build']); + grunt.registerMultiTask('swatch', 'build a theme', function() { + var t = this.target; + grunt.task.run('build:'+t); + }); + + grunt.registerTask('default', 'build a theme', function() { + grunt.task.run('swatch'); }); -}; \ No newline at end of file +};