Merge branch 'gh-pages' of github.com:frapontillo/bootswatch into gh-pages
[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
6         // Project configuration.
7         grunt.initConfig({
8                 pkg: grunt.file.readJSON('package.json'),
9                 builddir: 'build',
10                 meta: {
11                         banner: '/**\n' +
12                                                 ' * <%= pkg.description %>\n' +
13                                                 ' * @version v<%= pkg.version %> - ' +
14                                                 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
15                                                 ' * @link <%= pkg.homepage %>\n' +
16                                                 ' * @license <%= pkg.license %>' + ' */'
17                 },
18                 swatch: {
19                         amelia: {}, cerulean:{}, cosmo:{}, cyborg:{}, journal:{}, readable:{},
20                         shamrock:{}, simplex:{}, slate:{}, spacelab:{}, spruce:{}, superhero:{},
21                         united:{}
22                 },
23                 clean: {
24                    build: {
25                            src: ['*/build.less', '*/build-responsive.less',
26                                    '!global/build.less', '!global/build-responsive.less']
27                    }
28                 },
29                 concat: {
30                         dist: {
31                                 src: [],
32                                 dest: ''
33                         }
34                 },
35                 recess: {
36                         dist: {
37                                 options: {
38                                         compile: true,
39                                         compress: false
40                                 },
41                                 files: {}
42                         }
43                 }
44         });
45
46         grunt.registerTask('none', function() {});
47
48         grunt.registerTask('build', 'build a regular theme', function(theme, compress) {
49                 var compress = compress == undefined ? true : compress;
50
51                 var concatSrc;
52                 var concatDest;
53                 var recessDest;
54                 var recessSrc;
55                 var files = {};
56                 var dist = {};
57                 concatSrc = 'global/build.less';
58                 concatDest = theme + '/build.less';
59                 recessDest = '<%=builddir%>/' + theme + '/bootstrap.css';
60                 recessSrc = [ theme + '/' + 'build.less' ];
61
62                 dist = {src: concatSrc, dest: concatDest};
63                 grunt.config('concat.dist', dist);
64                 files = {}; files[recessDest] = recessSrc;
65                 grunt.config('recess.dist.files', files);
66                 grunt.config('recess.dist.options.compress', false);
67
68                 grunt.task.run(['concat', 'recess:dist', 'clean:build',
69                         compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap.min.css':'none']);
70         });
71
72         grunt.registerTask('build-responsive', 'build a responsive theme', function(theme, compress) {
73                 var compress = compress == undefined ? true : compress;
74
75                 var concatSrc;
76                 var concatDest;
77                 var recessDest;
78                 var recessSrc;
79                 var files = {};
80                 var dist = {};
81
82                 concatSrc = 'global/build-responsive.less';
83                 concatDest = theme + '/build-responsive.less';
84                 recessDest = '<%=builddir%>/' + theme + '/bootstrap-responsive.css';
85                 recessSrc = [ theme + '/' + 'build-responsive.less' ];
86
87                 dist = {src: concatSrc, dest: concatDest};
88                 grunt.config('concat.dist', dist);
89                 files = {}; files[recessDest] = recessSrc;
90                 grunt.config('recess.dist.files', files);
91                 grunt.config('recess.dist.options.compress', false);
92
93                 grunt.task.run(['concat', 'recess:dist', 'clean:build',
94                         compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap-responsive.min.css':'none']);
95         });
96
97         grunt.registerTask('compress', 'compress a generic css', function(fileSrc, fileDst) {
98                 var files = {}; files[fileDst] = fileSrc;
99                 grunt.log.writeln('compressing file ' + fileSrc);
100
101                 grunt.config('recess.dist.files', files);
102                 grunt.config('recess.dist.options.compress', true);
103                 grunt.task.run(['recess:dist']);
104         });
105
106         grunt.registerMultiTask('swatch', 'build a theme, both not responsive and responsive', function() {
107                 var t = this.target;
108                 grunt.task.run('build:'+t, 'build-responsive:'+t);
109         });
110 };