first commit for 3.0.0-rc1
[bootswatch] / Gruntfile.js
1 module.exports = function (grunt) {
2         grunt.loadNpmTasks('grunt-recess');
3         grunt.loadNpmTasks('grunt-contrib-concat');
4         grunt.loadNpmTasks('grunt-contrib-clean');
5         grunt.loadNpmTasks('grunt-contrib-watch');
6
7         // Project configuration.
8         grunt.initConfig({
9                 pkg: grunt.file.readJSON('package.json'),
10                 builddir: '.',
11                 meta: {
12                         banner: '/**\n' +
13                                                 ' * <%= pkg.description %>\n' +
14                                                 ' * @version v<%= pkg.version %> - ' +
15                                                 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
16                                                 ' * @link <%= pkg.homepage %>\n' +
17                                                 ' * @license <%= pkg.license %>' + ' */'
18                 },
19                 swatch: {
20                         amelia:{}, cerulean:{}, cosmo:{}, cyborg:{}, flatly:{}, journal:{},
21                         readable:{}, simplex:{}, slate:{}, spacelab:{}, superhero:{}, united:{}
22                 },
23                 clean: {
24                         build: {
25                                 src: ['*/build.less', '!global/build.less']
26                         }
27                 },
28                 concat: {
29                         dist: {
30                                 src: [],
31                                 dest: ''
32                         }
33                 },
34                 recess: {
35                         dist: {
36                                 options: {
37                                         compile: true,
38                                         compress: false
39                                 },
40                                 files: {}
41                         }
42                 }
43         });
44
45         grunt.registerTask('none', function() {});
46
47         grunt.registerTask('build', 'build a regular theme', function(theme, compress) {
48                 var compress = compress == undefined ? true : compress;
49
50                 var concatSrc;
51                 var concatDest;
52                 var recessDest;
53                 var recessSrc;
54                 var files = {};
55                 var dist = {};
56                 concatSrc = 'global/build.less';
57                 concatDest = theme + '/build.less';
58                 recessDest = '<%=builddir%>/' + theme + '/bootstrap.css';
59                 recessSrc = [ theme + '/' + 'build.less' ];
60
61                 dist = {src: concatSrc, dest: concatDest};
62                 grunt.config('concat.dist', dist);
63                 files = {}; files[recessDest] = recessSrc;
64                 grunt.config('recess.dist.files', files);
65                 grunt.config('recess.dist.options.compress', false);
66
67                 grunt.task.run(['concat', 'recess:dist', 'clean:build',
68                         compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap.min.css':'none']);
69         });
70
71         grunt.registerTask('compress', 'compress a generic css', function(fileSrc, fileDst) {
72                 var files = {}; files[fileDst] = fileSrc;
73                 grunt.log.writeln('compressing file ' + fileSrc);
74
75                 grunt.config('recess.dist.files', files);
76                 grunt.config('recess.dist.options.compress', true);
77                 grunt.task.run(['recess:dist']);
78         });
79
80         grunt.registerMultiTask('swatch', 'build a theme', function() {
81                 var t = this.target;
82                 grunt.task.run('build:'+t);
83         });
84         
85         grunt.registerTask('default', 'build a theme', function() {
86                 grunt.task.run('swatch');
87         });
88 };